9 ms·
So your + operator implicitly casts booleans to an integer type, with false=0 and true=1?
by Ded7xSEoPKYNsDd 10y ago
So your + operator implicitly casts booleans to an integer type, with false=0 and true=1?
- simcop2387 10y agoIn c++, yes. Not every language will do that though.
- kmill 10y agoWhat you are saying is the only way I can imagine to interpret what I wrote, if one assumes I was intending to make any sense. By the way, in Python, bool is a subtype of int (i.e., instanceof(True,int) == True), and True + True == 2. C is the same, and in Javascript booleans are converted to integers for arithmetic operations.
- OJFord 10y ago> What you are saying is the only way I can imagine to interpret what I wrote One might imagine it (without experience, or not thinking, of any particular programming language) as being a logical OR on Booleans - which in EE at least is frequently written '+'.