Skip to main content

Questions tagged [booleans]

For questions about booleans, a data type representing logical values, typically either true or false.

Filter by
Sorted by
Tagged with
2 votes
5 answers

Which number should be considered as true/false?

What I want to ask is not the Boolean value at the type level, but the Boolean value in actual implementation. Because the ...
Aster's user avatar
  • 3,228
19 votes
10 answers

Are there any languages where conditions are not first-class expressions?

Novices writing in mainstream languages often don't realise that conditions like x < y are expressions which can occur anywhere an expression is syntactically ...
CPlus's user avatar
  • 8,301
20 votes
10 answers

What are the drawbacks of allowing implicit boolean/integer conversions?

Some languages (C, C++, JavaScript, Python) allow one to use integers as booleans and vice versa: int x; if (x) // Equivalent to: x != 0 y(); Or: ...
CPlus's user avatar
  • 8,301
9 votes
5 answers

How to make logical operators that return operands consistent in a statically typed language?

In C++, 3 || 4 returns true. But in Python, 3 or 4 returns 3 instead. That's a logical operator that returns its operand. I don'...
user23013's user avatar
  • 2,430
12 votes
6 answers

What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

I do not know of any languages that support this idea but I just thought that since numbers are just bits, why should we not be able to access those bits directly? In most languages such as C or C++, ...
CPlus's user avatar
  • 8,301