Posts ID:34662 Favorites Creations
 ID:34662   Sep 9 2007, 12:35 am Keywords: maths (Aside: I'm still looking for opinions on my previous post.) As programmers, we are used to the concept that non-zero numbers are true, and the number zero (that celebrated, deplored, curiosity-inspiring singularity squatting in the centre of an uncountably infinite line of numbers stretching forever in both directions, and then some) is false. Indeed, in C programming, 1 is so often synonymous with truth and 0 with falsehood that truth and falsehood are often literally defined as being equal to those numbers: ```#define TRUE 1 #define FALSE 0 ``` This has a few odd mathematical consequences, such as the number 2 being doubly true (TRUE+TRUE). More interestingly, if you try to divide TRUE into equal parts, the result will be rounded down to FALSE. I think there's something in that for all of us. But let us diverge from the topic of C programming, and once again speak more generally of the convention that all non-zero numbers are equally true. However! This universally-accepted convention is not, in fact, as universally-accepted as all that. In fact, in bash scripting, the world of truth and falsehood is turned on its head, zero becoming true and non-zero becoming false! You may gasp in shock and horror, but I assure you that this is indeed TRUE, no matter which value you assign to TRUE! What is this foul fiction? you cry! Alas, alack, have the Biblical revisionists finally taken over? Quick, somebody check if pi is equal to three! Don't panic; your transcendental numbers are safe. Except from the terrorists. (This interjection is brought to you by the US government.) Indeed, on reflection I must admit there is some strange, strange elegance in this strange, strange concept. For example, division by false is now routine. And is it not so that falsehoods cannot help but repeatedly divide us? Furthermore, falsehoods are dirty, common things; no more remarkable in our lives than the mathematical properties of the number 14. But the number 0; aah, now there is a strange and wondrous thing, as truth is a strange and wondrous thing! If my ramblings have not yet convinced you, consider this closing thought. If all non-zero numbers are true, then there are infinitely many truths and only one falsehood. However, as any man or woman may see, there exists more than one falsehood in the world. This leads one to suggest that the opposing scheme, containing but one truth and infinitely many falsehoods, is closer to reality.
 #1 Sep 9 2007, 12:37 am In truth (hah!), it is not productive to think of truth as being a binary quantity; one thing can be more true than another thing without the former being absolutely true and the latter being absolutely false. Computers, sadly, are fundamentally binary.
 #2 Sep 9 2007, 12:49 am Wait... So half-truths are now falsehoods? Shit! I'm gonna have to find a new way to not lie to my supervisors! That was pretty thought-provoking, Crispy. Mind boggling, but thought provoking.
 #3 Sep 9 2007, 1:22 am I can't live after reading this mind-shattering article.. *goes to get his gun*
 #4 Sep 9 2007, 3:43 am I'm so enlightened, now Flame Sage has to shoot me before himself -- way to go!
 #5 Sep 9 2007, 5:04 am High-tech sorcery! Burn Crispy at the stake! I want him nice and crispy!
 #6 Sep 9 2007, 7:30 am VB has 0 = true and 1 = false, so if we go on the premise that anything VB touches becomes suck, your philosophical argument instantly falls apart.
 #7 Sep 9 2007, 7:58 am I like this concept! Indeed, there can truly only be one ultimate truth... All others must approach that single, utmost truth... This, then, suggests that as their number representations approach 0, statements approach this one, single truth... So then, a statement with a truth "value" of 5 is the equivalent of one whose value is -5?
 #8 Sep 9 2007, 9:24 am Anyone else want to join me in my saying that I had absolutely no idea what Crispy was talking about until the last paragraph? I caught the Bash true = 0 thing, but I was looking for something in the other paragraphs that didn't pop out immediately. Further proof that all future reading should be forgone in exchange for nearly reading the last paragraph(s), be it in a blog post, article, or book. :P
 #9 Sep 9 2007, 10:24 am 0 is true in bash likely because a program that completes succesfully (truthfully?) returns an error code of 0.
 #10 Sep 9 2007, 7:47 pm It's the same way in DOS, generally -- and even in most C projects. Most C functions return 1 (or otherwise) for failure, 0 for success. "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." --Robert Firth This has actually inspired the convention where most programmers develop their procedures in the negative sense. For instance: if(SomethingHasFailed()) { ... } This is partially because many programmers hate indentation. What with smart indents and all, however, I vastly prefer: if(SomethingIsSuccessful()) { ... } ...mainly because I'm an eternal optimist inside (even though I'm a pessimist outside).
 #11 Sep 9 2007, 8:49 pm Elation wrote: VB has 0 = true and 1 = false, so if we go on the premise that anything VB touches becomes suck, your philosophical argument instantly falls apart. You're wrong, because it doesn't! In VB, -1 is true and 0 is false. Go ahead and check if you like. Why -1? Because -1 is all 1s in binary, and VB has no logical and/or/etc.; all its truth-table operators are binary operators. This mind-boggling awful flaw was corrected in VB.NET, but its legacy lingers. Jon88 wrote: 0 is true in bash likely because a program that completes succesfully (truthfully?) returns an error code of 0. Sure, that's the mundane reason. ;-)
 #12 Sep 10 2007, 2:47 am Sadly the absolute truth and many falsehoods philosophy is unlikely to be followed in newer languages. Exceptions supersede this convention.
 #13 Sep 10 2007, 3:01 am Well, though it might not need to be said (in a "Thank you Captain Obvious!" sort of way), I think the TRUE=1 and FALSE=0 philosophy has come about because of its parallel to binary itself... TRUE=ON and FALSE=OFF It's almost a Good vs Evil kind of thing... Light vs dark... Positive vs Negative (errr, scratch this one)