Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, this is more a case of “this could conceivably happen, so why not guard against it where it’s easy to do”. Though personally I would have used -1.


The BBC micro and Archimedes used -1 as true in BASIC.

It meant that you didn't need the distinction of "logical operators" (like && in C) and "bitwise operators" (like & in C). You could just use bitwise operators, e.g. the bitwise NOT operator would convert 0 (all bits clear) was -1 (all bits set) so there was no need for "logical operators".

I always felt that was more elegant than C (but of course required a two's compliment machine, which BBC/Archimedes was, but C didn't require).


This is only sound if you have a boolean type that guarantees that the bits are either all zero or all one. Once a mix of bit values is possible, you have to define whether it mean true or false, and then you can’t use the bitwise operators anymore.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: