Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

The best "true zero" is...

by tye  (Monk)
on Jun 08, 2005 at 04:21 UTC ( #464548=poll: print w/ replies, xml ) Need Help??

vote on The best "true zero" is...

Decimal ("0.0")
[bar] 154/17%
Exponential ("0E0")
[bar] 86/9%
Octal ("00")
[bar] 22/2%
Hex ("0x0")
[bar] 184/20%
Positive ("+0")
[bar] 30/3%
Negative ("-0")
[bar] 12/1%
Spacial (" 0")
[bar] 77/8%
Linear ("0\n")
[bar] 10/1%
Fractional (".0")
[bar] 6/1%
Periodic ("0.")
[bar] 9/1%
Larry's ("0 but true")
[bar] 279/30%
Also ("\t00")
[bar] 1/0%
Yule ("\n0e1")
[bar] 17/2%
Other ("+0.e-9")
[bar] 32/3%
919 total votes
Comment on The best "true zero" is...
Re: The best "true zero" is... ("winkie")
by tye (Cardinal) on Jun 08, 2005 at 04:27 UTC

    Note that "exponential" is also called "winkie", due to The Wizard of Oz.

    - tye        

Re: The best "true zero" is...
by mce (Curate) on Jun 08, 2005 at 08:41 UTC
    Isn't 0E0 and "Larry's 0 but true" the same? :-)

    ---------------------------
    Dr. Mark Ceulemans
    Senior Consultant
    BMC, Belgium

      No, it's really the string "0 but true". Try this for example:

      use File::Temp; $th = File::Temp::tempfile(undef, "UNLINK", 1); $zbt = + sysseek $th, 0, 0; print $zbt, "\n";

      The "E0" suffix appears with the flip-flop operators, but "0E0" can never appear, only "1E0", "2E0" etc.

        true, but also not true :-)

        Many functions -like the execute function in DBI- return 0E0 when they want to return a result that is ment to be zero but is 'boolean' true in tests

        So, indeed it is not general perl, but it is common to use 0E0 as "zero but true".

        Cheers,


        ---------------------------
        Dr. Mark Ceulemans
        Senior Consultant
        BMC, Belgium
      Isn't 0E0 and "Larry's 0 but true" the same? :-)

      Not at all. "0 but true" describes a state of data in Perl. "0E0" is part of the lyrics for the background singers in "Jungle Love" by Morris Day and the Time. Quite different.

      --
      tbone1, YAPS (Yet Another Perl Schlub)
      And remember, if he succeeds, so what.
      - Chick McGee

      No.

      $ perl -wle'print "0 but true" eq "0E0" ?1:0' 0

      They are both silently equal to zero yet true, but so are the other poll options (except "0x0").

      $ perl -wle'print 0+"0 but true"' 0 $ perl -wle'print 0+"0E0"' 0 $ perl -wle'print "0 but true" ?"true":"false"' true $ perl -wle'print "0E0" ?"true":"false"' true
Re: The best "true zero" is...
by marto (Chancellor) on Jun 08, 2005 at 09:08 UTC
    The dog named Zero from "The Nightmare before Christmas" is the one true zero :P

    Martin
      The dog named Zero from the book _Ordinary Jack_ is the one true dog named Zero.
        Tha kamikaze who survives the mission is one true zero.
Re: The best "true zero" is...
by rinceWind (Monsignor) on Jun 08, 2005 at 10:34 UTC

    Aha the naughty nought. I wonder how many others have been bitten by this with DBI return codes.

    Are any of the other true zero values used I wonder?

    --

    Oh Lord, wont you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, wont you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

Re: The best "true zero" is...
by herveus (Parson) on Jun 08, 2005 at 12:41 UTC
    Howdy!

    Hector Zeroni from Holes...or Zero in Beetle Bailey...

    yours,
    Michael
Re: The best "true zero" is...
by BrowserUk (Pope) on Jun 08, 2005 at 13:27 UTC

    Couldn't vote! The one true anything is just dogma.

    print scalar reverse 'dogma';

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
Re: The best "true zero" is...
by ikegami (Pope) on Jun 08, 2005 at 15:55 UTC

    Zero is nothing, so undef is the true zero!

    (If only undef didn't give warnings in arithmetic...)

Re: The best "true zero" is...
by kutsu (Priest) on Jun 08, 2005 at 18:48 UTC

    Other: Zero from the Megaman X series. ;)

    "Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce

Re: The best "true zero" is...
by sekitan (Sexton) on Jun 08, 2005 at 19:27 UTC
    how about our hero zero ( school house rock )
Re: The best "true zero" is...
by Anonymous Monk on Jun 08, 2005 at 21:05 UTC
      Absolutely!

      --hsm

      "Never try to teach a pig to sing...it wastes your time and it annoys the pig."
Re: The best "true zero" is...
by rdm (Hermit) on Jun 09, 2005 at 01:33 UTC
    IMHO, the best is 3D vector. [0,0,0]

    -Reality might not get out of Beta today. (O.Timas, "Bot")
Re: The best "true zero" is...
by grinder (Bishop) on Jun 09, 2005 at 08:22 UTC

    Couldn't vote! The one true zero is just 0. No plusses, dashes, letters, spaces or any other superfluous fluff :)

    update: yes, I am aware of the zero, true zero dichotomy which is what the poll is about. Let me just say... "truth wears many faces"

    - another intruder with the mooring in the heart of the Perl

      That's like saying that all primes are odd except 2 which is the oddest amongst all.

      The one true zero is just 0. No plusses, dashes, letters, spaces or any other superfluous fluff.

      Ah, but this poll isn't about the one true "zero" but about the best "true zero" — of the various values in Perl which are zero in numeric context but true in boolean context, which do you like best?

      Just "0" fails cos it's false, not true; you need some of that "superfluous fluff" to make it a "true zero".

      Smylers

Re: The best "true zero" is...
by vksbalaji (Initiate) on Jun 09, 2005 at 09:49 UTC
    Let Zero be the way it is why prefix or suffix it.....
Re: The best "true zero" is...
by theorbtwo (Prior) on Jun 09, 2005 at 10:41 UTC

    A lot of people don't seem to understand the poll... or I'm not getting their jokes, which is also possible.

    Anyway, there is sometimes a wish for something that is considered zero when used in numeric context, but true when used in boolean context, that is something that will make the following print "42\n":

    #!/usr/bin/perl use warnings; use strict; my $x='<some choice on the poll>'; print $x+42, "\n" if ($x);


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: The best "true zero" is...
by jdhedden (Deacon) on Jun 09, 2005 at 13:32 UTC
    I abstain from voting.
    IMHO, the motivation for the poll is pathological. You're asking for the best obfuscation (yes, an oxymoron) for lazy programmers to use.
    If you want zero to be true in a conditional, then the correct test is 'defined()'.

      There is a difference. For example, DBI's do() returns the number of rows affected -- but some statements succeed even though no rows were affected. This allows for the following bit of code to be sane:

      my $rows = $dbh->do( 'UPDATE MyTable SET note_date = GETDATE() WHERE ErrorCode IS NOT NULL' ); if ($rows) { # true, even if zero rows were affected. print 'Found and updated rows: (',$rows,")\n"; } else { warn 'Error during update query'; }

      Having a query affect zero rows is perfectly valid, and doesn't necessarily mean an error. This makes even more sense when other methods in the same program return '0' as the false value rather than undef: it allows for programmer choice and a consistent read.

      Larry Wall is Yoda: there is no try{}
      The Code that can be seen is not the true Code
Re: The best "true zero" is...
by gloryhack (Deacon) on Jun 10, 2005 at 07:24 UTC
    What does it mean? It means nothing. It is as it is and has no need for meaning.
        -- Edward Abbey, Desert Solitaire
Re: The best "true zero" is...
by Paulster2 (Priest) on Jun 10, 2005 at 13:00 UTC

    Kelvin might have an absolute for you.

    Paulster2


    You're so sly, but so am I. - Quote from the movie Manhunter.

        Zapato is totally whacked....

        Paulster2


        You're so sly, but so am I. - Quote from the movie Manhunter.
Re: The best "true zero" is...
by mattr (Curate) on Jun 14, 2005 at 07:59 UTC
    I misplaced the data but believe it begins like dd if=/dev/zero of=/dev/hda
Re: The best "true zero" is...
by pikus (Hermit) on Jun 14, 2005 at 13:56 UTC
    Exponential makekes me think of Morris Day and the Time. 0E0E0! My Jungle Love!
         - pikus
    "I want to live 'till I die. No more. No less." - Eddie Izzard
Re: The best "true zero" is...
by gwhite (Friar) on Jun 16, 2005 at 11:32 UTC

    Number of times I have been right, according to my wife.

    g_White
      'Wife'? Then she must admit you've been right at least once... ;)

        Her version is she picked me....

        g_White
Re: The best "true zero" is...
by NateTut (Deacon) on Jun 17, 2005 at 14:58 UTC
    I think this is much ado about nothing.

    P.S.

    My favorite is the textual "zero"
      There may be many ways to skin a cat, but only an escaped lunatic would actually try them out in practice. (-S)
Re: The best "true zero" is...
by apotheon (Deacon) on Jul 01, 2005 at 02:07 UTC

    The one true zero is

    print substr("Just another Perl hacker", 0, -2);
    - apotheon
    CopyWrite Chad Perrin

Re: The best "true zero" is...
by jonadab (Parson) on Jul 06, 2005 at 14:06 UTC

    The thing I like about "0 but true" is that it is self-explanatory; with any of the others, I'd feel obligated to insert a comment explaining why I was returning zero in that particular way, so that some hapless soul a few years later doesn't pull out hair figuring out why my code is so weird; with "0 but true" I expect any decent Perl programmer to be able to figure it out, because the jist of the reason is contained in the value; assuming the reader understands context, it'll just click. (And if the reader doesn't understand context, he won't be able to maintain my code anyway; I make frequent use of context and consider it a major concept of the language.)

Re: The best "true zero" is...
by Dove_From_Above (Initiate) on Jul 08, 2005 at 15:36 UTC
    Surely the best definition of true zero is "Sigma (everything) == 0". Where everything includes all real, rational, irrational, transcendental and imaginary numbers, concepts, thought processes, definitions of zero, snippets of code, people, things, space, vacuums, natures abhoring vacuums, lumps of rock, B list movie stars etc etc etc. Otherwise you imply that existance actually has a starting point (and where did that starting point come from ... ) (and where did that starting point starting point come from ....) onto infinity ... rather than being either just there or illusionary or pre-determined. Personally I like Larry's ("0 but true") statement as a good description of existence.
Re: The best "true zero" is...
by 2shortplanks (Initiate) on Jul 08, 2005 at 16:33 UTC
    use Scalar::Util qw(dualvar); my $true_zero = dualvar(0,"my true zero is better than yours");
    Since that's a real zero. None of this string being parsed as zero stuff.
Re: The best "true zero" is...
by Anonymous Monk on Mar 02, 2009 at 06:00 UTC
    to describe true zero utilizing computer binary code processed into the form of black font, is to defeat the purpose of materializing nothing. The though of zero is the manifestiotion of more than zero, therefor to ask people to represent zero is to ask them to edify a sum higher than the topic thereof. It is for this reason that zero was the lack of thought dwelling in the depths of conciosness before my brain processed your question posted in this thread, assuming that I was lost in the though of oblivion, in which case a sum greater than 0 consisted therein. This is all based on the theory that the mind is a product of geneticly stored data in cell memory, and the enviornment surrounding hosts while expanding creates their thought patterns. Nothing is nothing is somthing because you are processing it.
Re: The best "true zero" is...
by ikegami (Pope) on Jul 28, 2010 at 16:31 UTC
    $ perl -wle'print 0+"0x0"' Argument "0x0" isn't numeric in addition (+) at -e line 1. 0

    Behaviour change or bad poll option?

    Update: 5.3 warned.

View List Of Past Polls


Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-07-31 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls