3 ms·
0 and 1 are iconic for true and false.
by mixmastamyk 4y ago
0 and 1 are iconic for true and false.
- ok_dad 4y agoBecause true and false used to just be 1 and 0, not for any good or thoughtful reasons (much of tech is the way it is because of constraints we no longer have). Today, new languages should avoid pitfalls like truthiness and null values.
- mixmastamyk 4y agoThey are both good and thoughtful, fundamental to how computers work.
- ok_dad 4y agoI guess it wouldn’t matter much without null values, or if they made null values neither true nor false then it might fix it. If not for null then truthiness wouldn’t seem as dangerous to me, I think. As far as zero and one; if you compare equality on a machine you’re generally doing an xor type operation between the two values and if they’re equal you get zero, so that’s flipped. If you’re comparing two numbers it might even result in a ternary value of LT, EQ, and GT. I think true and false are high level programming language or mathematical concepts that don’t map directly to the low level testing results. So, I don’t really consider the traditional “true is 1, false is 0” to be anything more than convenient abstractions in programming based on things that some folks did for convenience at the beginning of software development.
- coldtea 4y ago0 perhaps. 1 doesn't mean much regarding true, if every other non-zero integer is also true.
- mixmastamyk 4y agoBinary 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.