2 ms·
Binary numbers and electronics would like a word with you.
by mixmastamyk 4y ago
Binary numbers and electronics would like a word with you.
- rvense 4y agoI don't know, a boolean is usually a byte (or a words?), so should true really be 0b00000001? Why not 0b11111111? I think it is in some Forth implementations.
- coldtea 4y agoTalking about integer values treated as false/true in a language without first class booleans. Not about the use of 0 and 1 in binary. And my point is that since 0 alone is treated as false among integers in those cases, it can be considered as iconic or "standard". But since any other integer is true, 1 is not much of the "canonical" true, but just one of billions of others. In binary it's 0 and 1 alone, so the comment doesn't apply there.
- ok_dad 4y agoAlso, if you compare the equality two binary strings using an xor, you get zero for equal. Zero and one have no specific meaning in binary logic other than being the symbols used for binary strings; they’re just abstractions that were used by the first programmers to indicate true and false before languages has dedicated atoms for those concepts.
- mixmastamyk 4y agoPython has first class bools. If you don’t want to test an integer, if it doesn’t meet your needs, don’t use it. There are an unlimited number of other choices for comparisons.
- coldtea 4y agoThe problem is that it also has second-class bools (other stuff service as booleans). First class bools alone being logic-checked, is a better design.
- SamReidHughes 4y agoIn C and other such languages, the comparison operators return 0 or 1. So that gives 1 special status.