The Daily WTF: Curious Perversions in Information Technology
Welcome to TDWTF Forums Sign in | Join | Help
in Search

One day, one will be zero

Last post 05-17-2008 2:42 AM by Cap'n Steve. 16 replies.
Page 1 of 1 (17 items)
Sort Posts: Previous Next
  • 05-15-2008 5:35 AM

    One day, one will be zero

    Currently working on an very old VBA-Excel app, using dozens of undefinded Variables with names like xz, x2, ww, nn and so on. But this one made my day:

    If UCase(vergl) = UCase(richtig) And eins = 0 Then

    ("eins" is the german word for "one")

     

  • 05-15-2008 5:48 AM In reply to

    • dtech
    • Top 50 Contributor
    • Joined on 11-13-2007
    • Utrecht, Netherlands
    • Posts 623

    Re: One day, one will be zero

    funthomas:

    Currently working on an very old VBA-Excel app, using dozens of undefinded Variables with names like xz, x2, ww, nn and so on. But this one made my day:

    If UCase(vergl) = UCase(richtig) And eins = 0 Then

    ("eins" is the german word for "one")

     

    Obviously this is to prevent the infamous MathRulesHaveChanged() exception.
    NerdTests.com says I'm a Cool Nerd King.  Click here to take the Nerd Test, get nerdy images and jokes, and write on the nerd forum!
  • 05-15-2008 7:36 AM In reply to

    • why?
    • Not Ranked
    • Joined on 09-10-2007
    • Posts 9

    Re: One day, one will be zero

    I assume this is a critical application, the check for memory corruption is valid in such circumstances.
  • 05-15-2008 8:15 AM In reply to

    Re: One day, one will be zero

    why?:
    I assume this is a critical application, the check for memory corruption is valid in such circumstances.
     

    But this would be checking the wrong cell, and if eins is really 1 (which we can only hope), then the check should be for eins!=1, since it could be corrupted to any non-unity value.  Furthermore, if this was a check for memory corruption, then there would be no point in checking the other test. This leads me to suspect that eins is instead a badly-named flag for something, which makes this not much of a WTF.

  • 05-15-2008 9:29 AM In reply to

    • operagost
    • Top 150 Contributor
    • Joined on 03-19-2007
    • Pennsylvania, USA
    • Posts 262

    Re: One day, one will be zero

     Or someone decided this would be easier than commenting out the code.

  • 05-15-2008 9:32 AM In reply to

    Re: One day, one will be zero

     TRWTF is...ah, to hell with it...

    "The world of technical support is like a reflecting pool. To those who exist outside, it appears to be a deep, mystical place; bottomless, terrifying, foreign. The truth, however, is that the pool is only about three feet deep, and the bottom is grainy silt over sharp, hurty rocks."
  • 05-15-2008 9:39 AM In reply to

    • ammoQ
    • Top 10 Contributor
    • Joined on 04-13-2005
    • Vienna.Austria.Europe.Earth
    • Posts 3,445

    Re: One day, one will be zero

    funthomas:

    If UCase(vergl) = UCase(richtig) And eins = 0 Then

    Always remember: "einmal ist keinmal" (roughly "once is never"),

    so you'll probably find

        eins=0;

    somewhere else 

    beanbag girl 4ever
  • 05-15-2008 10:08 AM In reply to

    Re: One day, one will be zero

    Physics Phil:
    This leads me to suspect that eins is instead a badly-named flag for something, which makes this not much of a WTF.

    You're right, it's used as a flag. However:

    • It has a complete useless and irritating name (even the name "flag" would make more sense...)
    • it uses 0 and 1 instead of false and true (no, "FileNotFound" not needed here)
    • it is completly unneccessary (you cannot see this from the snippet, but it is like that, I've removed it in the meantime) 

    How much of a WTF have you found in your code that you think that this is not much of a WTF?

     

  • 05-15-2008 10:38 AM In reply to

    Re: One day, one will be zero

    funthomas:

    You're right, it's used as a flag. However:

    • it uses 0 and 1 instead of false and true (no, "FileNotFound" not needed here)

     QBASIC (old DOS BASIC from Microsoft) used 0 for false and -1 for true.  Also, bitwise and logical operators were combined, which is the reason for -1 = true so that FALSE = NOT(TRUE).  I don't know if Visual Basic has actual booleans (probably does), but if it doesn't then we have 1 = "true", 0 = false, -1 = "it's really true I mean it", and -2 = "file not found".

  • 05-15-2008 11:28 AM In reply to

    Re: One day, one will be zero

    funthomas:

    undefinded Variables with names like xz, x2, ww, nn

    funthomas, are you oaky?  Did spectate get to you?  Are you in a swamp shack?  Do you need help? :)

  • 05-15-2008 11:46 AM In reply to

    Re: One day, one will be zero

    but of course everyone uses VBA for critical appliations...

  • 05-15-2008 8:43 PM In reply to

    Re: One day, one will be zero

    One day, one will be zero
    Is that a zero day vulnerability?

    Mass Effect 2 FTW!

    lolwtf: Instead of comfy chair, package contained bobcat. Would not buy again.
    curtmack: It's like Godwin's Law, but instead of Hitler it's xkcd references.
    morbiuswilters: Right, but the Holocaust wasn't nearly as bad as xkcd.
  • 05-16-2008 5:47 AM In reply to

    Re: One day, one will be zero

    samanddeanus:
     QBASIC (old DOS BASIC from Microsoft) used 0 for false and -1 for true.  Also, bitwise and logical operators were combined, which is the reason for -1 = true so that FALSE = NOT(TRUE).
    A manual for an old basic dialect that used true = -1 claimed the reason was that 0 = 0b00000000 and -1 = 0b11111111, and those values wouldn't be changed between each other by memory corruption. Or something. I'm not sure. It does strike me as a nice (if devoid of any real merit) thing to have, that true = bitwisenot(false), and if treated as a signed byte, that makes true = -1.

    TRWTF is Community Server
  • 05-16-2008 7:23 AM In reply to

    Re: One day, one will be zero

    m0ffx:

    samanddeanus:
     QBASIC (old DOS BASIC from Microsoft) used 0 for false and -1 for true.  Also, bitwise and logical operators were combined, which is the reason for -1 = true so that FALSE = NOT(TRUE).
    A manual for an old basic dialect that used true = -1 claimed the reason was that 0 = 0b00000000 and -1 = 0b11111111, and those values wouldn't be changed between each other by memory corruption. Or something. I'm not sure. It does strike me as a nice (if devoid of any real merit) thing to have, that true = bitwisenot(false), and if treated as a signed byte, that makes true = -1.

     

     

    from what i remember, visual basic still uses this values for boolean true and false, but in addition, when you ask for a numeric value of it, it does some conversions and returns 1 for true and 0 for false 

    Sometimes I wish I could not post before I stop, and actually check whether there isn't anything similar to what i want to write...
  • 05-16-2008 7:44 AM In reply to

    • ammoQ
    • Top 10 Contributor
    • Joined on 04-13-2005
    • Vienna.Austria.Europe.Earth
    • Posts 3,445

    Re: One day, one will be zero

     I guess the one and only reason for true == -1 in old BASIC was that it allowed the same operators (i.e. NOT) to be used for boolean and bitwise operations. When the whole BASIC (along with the primitive operating system) has to fit into 8K of ROM, you don't want two sets of logical operators.

    "Memory corruption" is an absolutely moronic explanation. If that kind of things happen, your system will happily crash anyway.

    beanbag girl 4ever
  • 05-16-2008 12:52 PM In reply to

    Re: One day, one will be zero

    Unless the author of the code added Option Compare Binary to the module UCase wasn't needed to begin with ... anyone that doesn't realize this probably shouldn't be expected to use hungarian notation or any variable names that actually mean anything.

     


    There are three kinds of people: those who make things happen, those who watch things happen and those who wonder what happened.
  • 05-17-2008 2:42 AM In reply to

    Re: One day, one will be zero

    ammoQ:
    "Memory corruption" is an absolutely moronic explanation. If that kind of things happen, your system will happily crash anyway.
    Was BASIC ever used in space? I guess that might help slightly with radiation randomly flipping bits.
Page 1 of 1 (17 items)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems