Skip to main content

Timeline for Why is 0 false?

Current License: CC BY-SA 4.0

52 events
when toggle format what by license comment
Sep 3, 2023 at 20:29 answer added gnasher729 timeline score: 0
S Sep 3, 2023 at 14:08 history suggested CPlus CC BY-SA 4.0
Fixed grammar and removed unnecesary part
Jul 16, 2023 at 22:09 review Suggested edits
S Sep 3, 2023 at 14:08
Jul 9, 2023 at 20:15 answer added jimc timeline score: 2
Jan 13, 2020 at 2:36 comment added HostileFork says dont trust SE I lament my opinion that non-primes are false and primes are true has never really been taken seriously.
Aug 2, 2017 at 19:32 comment added james I find it odd how PayPal RESULT values use 1(or any non-zero) for not approved and 0 for approved which i related to 1(or non-zero) being false and 0 being true in this case(whether a transaction was successful without error or not): paypalobjects.com/en_US/vhelp/paypalmanager_help/…
Aug 2, 2017 at 19:16 history edited Deduplicator CC BY-SA 3.0
added syntax-highlighting
Jun 7, 2017 at 18:51 comment added kayleeFrye_onDeck Exit codes != true/false... you may have designed your exit codes to react that way, but some of us use exit codes to determine all manner of things. Exit 0 is the standard return for a successful exit of a program, but that doesn't somehow mean 0 in a shell somehow universally becomes synonymous with true.
Apr 13, 2017 at 12:19 history edited CommunityBot
replaced http://math.stackexchange.com/ with https://math.stackexchange.com/
Jul 28, 2014 at 14:15 comment added ctrl-alt-delor Is it? In C, 0 is false, all other values are true. However in sh the unix shell, 0 is true, all other values are false. (C and sh where written around the same time, as part of Unix. Unix is mostly consistent, but not here.)
Jul 28, 2014 at 13:07 answer added Basile Starynkevitch timeline score: 4
Apr 10, 2014 at 18:54 answer added 200_success timeline score: 17
Nov 12, 2013 at 20:03 comment added JensG if (some_function() == TRUE) I always cringe when I read code like this. That's just plain awkward.
Sep 5, 2013 at 7:02 comment added Pieter B You shouldn't evaluate integer values to booleans at all. It's like casting a type with a lot of possible values to a type with only two possible values.
May 22, 2013 at 9:37 vote accept Morwenn
May 22, 2013 at 3:03 review Close votes
May 22, 2013 at 11:27
May 17, 2013 at 12:47 comment added user60812 I would think, and likely wrong :), that 0 is false and 1 is true (not case in c++, with any positive int true), comes from the days of computers being programmed electronically. That is to say electrical signal gets sent, or doesn't to a pin. Kind of like a lightswitch on is I, off is O. So 0 is no electric, 1 is electric flow
May 16, 2013 at 14:47 comment added afsantos On a logic perspective, false (the strongest of conditions) is stronger than true (the weakest of conditions). Representing a (binary) zero could be expressed as there are no ones, which is stronger, hence harder to satisfy, than there could be ones.
May 16, 2013 at 12:10 comment added Bakuriu @MasonWheeler Having a boolean type doesn't imply anything. For example python does have a bool type but comparisons/if conditions etc. can have any return value.
May 16, 2013 at 12:00 history edited Morwenn CC BY-SA 3.0
Added a little follow-up.
May 16, 2013 at 10:44 answer added Svish timeline score: 28
May 16, 2013 at 9:47 comment added Giorgio @TC1: Right, in Scheme numbers are also equivalent to true = #t. Additionally, you have a special symbol for false, namely #f, which is not the same as the empty list '().
May 16, 2013 at 9:35 review Close votes
May 16, 2013 at 12:09
May 16, 2013 at 9:34 answer added Tim Williscroft timeline score: 4
May 16, 2013 at 9:17 comment added TC1 @Giorgio Not just Common, afaik, LISP in general, at least I'm sure of Scheme, Clojure and Elisp. They're all fairly similar on those kinds of things. Still, that's 4 then.
May 16, 2013 at 8:44 comment added SK-logic There are no booleans in hardware whatsoever, only binary numbers, and in most historical ISAs a non-zero number is considered as "true" in all the conditional branching instructions (unless they're using flags instead). So, the low level languages are by all means obliged to follow the underlying hardware properties.
May 16, 2013 at 8:31 comment added Giorgio @TC1: You can add Common Lisp to the list (no pun intended): false is represented by nil (the empty list). When considered as boolean values, both 0 and 1 are equivalent to T (true), as all other numbers.
May 16, 2013 at 5:12 comment added ruakh @KeithThompson: In Bash (and other shells), "success" and "failure" really are the same as "true" and "false". Consider, for example, the statement if true ; then ... ; fi, where true is a command that returns zero and this tells if to run ....
May 16, 2013 at 3:47 answer added Jon Purdy timeline score: 108
May 16, 2013 at 1:16 answer added Kaz timeline score: 3
May 16, 2013 at 0:10 comment added Jörg W Mittag What are those languages you are talking about? In my personal experience, in most languages, 0 in a Boolean context is either truthy or a TypeError. The languages in which 0 is considered falsy seem to be a tiny minority, and the ones in which 0 actually is false can be counted on the fingers on one hand.
May 15, 2013 at 23:06 history tweeted twitter.com/#!/StackProgrammer/status/334807152130674688
May 15, 2013 at 22:36 history protected CommunityBot
May 15, 2013 at 22:30 comment added TC1 @MasonWheeler I could probably list the (reasonably popular) languages where 0 != FALSE on the fingers of 1 hand -- Haskell, Ada and Java off the bat, maybe a couple of others.
May 15, 2013 at 22:30 comment added meisterluk Just to mention that Lua does not imply that "0" corresponds to false. luafaq.org/gotchas.html#T2
May 15, 2013 at 22:21 answer added Giorgio timeline score: 19
May 15, 2013 at 22:01 answer added Neil G timeline score: 6
May 15, 2013 at 21:36 answer added svick timeline score: 6
May 15, 2013 at 21:30 comment added Morwenn @KeithThompson Depends whether the truth tables work with success and failure in Bash, right?
May 15, 2013 at 21:27 comment added Keith Thompson @ott--: In Unix shells, 0 means success and non-zero means failure -- not quite the same thing as "true" and "false".
May 15, 2013 at 21:23 answer added user44761 timeline score: 8
May 15, 2013 at 21:17 answer added Jon Raynor timeline score: 0
May 15, 2013 at 20:30 history edited Morwenn CC BY-SA 3.0
Deleted the note seems people are happy bitching about this question here and already retagged it :)
May 15, 2013 at 20:28 comment added Morwenn @ott-- Well, just asking about boolean values would be meaningless, my question exactly about why things are converted that way to boolean values :) Nice thing you cited Bash, I had almost forgotten about that one.
May 15, 2013 at 20:27 comment added ott-- strcmp() is no good example for true or false, as it returns 3 different values. And you will be surprised when you start using a shell, where 0 means true and anything else means false.
May 15, 2013 at 20:08 answer added joshin4colours timeline score: 41
May 15, 2013 at 19:52 answer added Robert Harvey timeline score: 77
May 15, 2013 at 19:52 answer added DeadMG timeline score: -8
May 15, 2013 at 19:47 history edited FrustratedWithFormsDesigner
edited tags
S May 15, 2013 at 19:47 history suggested R. Martinho Fernandes
Better tags, I think.
May 15, 2013 at 19:44 review Suggested edits
S May 15, 2013 at 19:47
May 15, 2013 at 19:37 history asked Morwenn CC BY-SA 3.0