• (cs)
    Jake Vinson:
    And finally, Allison B. sent in this entry on Octobe#ERROR: DATE DOES NOT EXIST
    /* note, system uses 360 days in a year, not 365 */

    Ok, this definitely falls in the category of bad-and-I-almost-guarantee-not-fun code. Sort of a warning: "Abandon all hope, ye who enter here."

  • Andy Ross (unregistered)

    The "(int)0.5 + radius" has a precedence bug that makes it a noop, but it isn't as dumb as it looks.  Using (int)(0.5 + x) is a quick & easy way to get proper rounding behavior of positive (!) floating point values.  If the code is in C, note that there are portability issues with functions like round() and rint(), and the above code might actually be preferred in some environments.

  • (cs)
    protected string buildGroupLink(string aIsGroup)
    {
            return "42";
    }

    I'm reminded of the "infinite defects methodology" mentioned in Joel's tale of Microsoftian woe (see test item #5). Maybe whoever wrote this was on a death march, in a situation where there's heavy time pressure to check in code, and evaluating whether it works properly or not will just wait until the next phase in the project? If so, the code WTF is simply a symptom of the management/planning WTF that is The Real WTF™.

    /* note, system uses 360 days in a year, not 365 */

    What, are they using the ancient Babylonian calendar, or something?

    Oh yeah: fist!

  • (cs)

    private static Language Italian = new Language("Italian"); // linguini-eating mobsters
    Someone has eaten too much copy-pasta. :) 
    Or too much Monty Python, for that matter: 

    "<font id="Michael">Good evening and welcome to another edition of 'Prejudice' - the show that gives you a chance to have a go at Wops, Krauts, Nigs, Eyeties, Gippos, Bubbles, Froggies, Chinks, Yidds, Jocks, Polacks, Paddies and Dagoes."</font>

     

  • (cs) in reply to kmactane

    Three lefts are not, in fact, a right, as Chris C. shows.

    1000 GOTO 1002
    1001 GOTO 1010
    1002 GOTO 1001
     
    I dont get it. Please help me.... maybe it is so clear to see that I dont see it.
  • (cs)
    Alex:
    @{$gst}{keys %{$rec}} = values %{$rec}; # muhahahaha

    Is it bad that I understood this instantly?

    I actually did benchmarks for methods of combining two hashes in perl, and this method seems to be significantly faster than any others I tried. I think it looks a lot nicer without all those optional braces, tho:

    @$gst{keys %$rec} = values %$rec;

    And as for the comment... well, I'm gonna have to confess to using similar comments myself. Code can be evil-genious-y without being inappropriate for serious projects, IMO.

  • (cs) in reply to kmactane
    kmactane:
    protected string buildGroupLink(string aIsGroup)
    {
    return "42";
    }

    I'm reminded of the "infinite defects methodology" mentioned in Joel's tale of Microsoftian woe (see test item #5). Maybe whoever wrote this was on a death march, in a situation where there's heavy time pressure to check in code, and evaluating whether it works properly or not will just wait until the next phase in the project? If so, the code WTF is simply a symptom of the management/planning WTF that is The Real WTF™.

    /* note, system uses 360 days in a year, not 365 */

    What, are they using the ancient Babylonian calendar, or something?

    Oh yeah: fist!

    It's the Egyptian calendar as far as I know. (Yes, those piramid-building, beer-drinking weasels.:))

  • (cs)

    Jake Vinson:

    And finally, Allison B. sent in this entry on Octobe#ERROR: DATE DOES NOT EXIST

    /* note, system uses 360 days in a year, not 365 */

    That's an artifact of the financial world.

    And before anyone shoots me down, my source is Wikipedia, which is flawless and infallible.  So there.

  • (cs)
    Jake Vinson:

    Ricky H.'s find speaks for itself.

    if b = b then
    b = true
    end if 

    Looks like the "poor man's conditional breakpoint" again.

    Any btw, I really like the earlier post time of the wtf.  Reading it after lunch is great!

  • Shadowman (unregistered)
    intRadius = (int)0.5 + radius;
     
    So this just adds 0 to the radius?  
     
    captcha = captcha :) 
  • Abigail (unregistered) in reply to Andy Ross

    But he didn't put in the parentheses, and therefore, he made it onto WTF.

  • Alexander Temerev (unregistered) in reply to Jon Sagara

    360-day calendar is used for a reason. Try to estimate the value of December call option for your favourite company using only your HP-12C calculator, given the fact that options expire at third Friday of every month.

  • Gedoon (unregistered)
    Jake Vinson:

    And finally, Allison B. sent in this entry on Octobe#ERROR: DATE DOES NOT EXIST

    /* note, system uses 360 days in a year, not 365 */

    There's nothing strange about this. it's common especially in some European countries banking system that a year has always exactly 260 days, a month always has 30 days. It's for calculating daily and yearly interest and stuff like that. Interesting, isn't it?

  • Cyan (unregistered) in reply to Nachoo
    Nachoo:

    Three lefts are not, in fact, a right, as Chris C. shows.

    1000 GOTO 1002
    1001 GOTO 1010
    1002 GOTO 1001
     
    I dont get it. Please help me.... maybe it is so clear to see that I dont see it.

     

    You've never used a GOTO statement before, have you? Think of it as the following:

    void FunctionOne(void)
    {
        FunctionTwo();
    }
    void FunctionTwo(void)
    {
        FunctionThree();
    }
    void FunctionThree(void)
    {
        // Program code here
    }
    

     

    Hope be with ye,
    Cyan

    captcha: tango - it takes two
     

  • (cs)
    Jake Vinson:

    Let's get things started with Michael, who shows us the easy way to calculate radii!

    intRadius = (int)0.5 + radius;

    Looks like this is from Javascript.

    radius is some string and to get this value into an integer, well one hack was to add 0 to it.

    Not elegant though. 

    Jake Vinson:

    And finally, Allison B. sent in this entry on Octobe#ERROR: DATE DOES NOT EXIST

    /* note, system uses 360 days in a year, not 365 */

    Yea, from the financial world. Some ( nine, I think ) special ways for calculating interest. The more complex ways to calculate interest, give more benefits to the account holder.

  • Hamilton Lovecraft (unregistered) in reply to Abigail

    Anonymous:
    But he didn't put in the parentheses, and therefore, he made it onto WTF.

    That makes it a bug, not a WTF. The Real WTF is that neither the submitter nor the editor apparently understood the coder's intent.

  • Jimbo (unregistered) in reply to rmr

    Note: If b=false then would come out of that equation equal to true.  The if... then is completley unneeded.  Now what the poor guy was meaning to do is a whole different matter.

  • (cs)
    Jake Vinson:

    Three lefts are not, in fact, a right, as Chris C. shows.

    1000 GOTO 1002
    1001 GOTO 1010
    1002 GOTO 1001

     

    How old are some of these?

    I'll step up and tell you that I cut my programming teeth on BASIC with line numbers. I'll also offer a guess as to how this ended up in the wild.

    Depending on the machine and the BASIC variant, jumping over a line of code might be easier than 'commenting it out.' Some of those old built-in editors were onery, and it was much easier to use a GOTO to jump over a suspect line. (Line 1002 might have just been something like 1002 REM - DEBUGGING.) Then, after that line was checked, the programmer, again avoiding the editor, just changed line 1002 to jump to the original line. Why not 1010? Hey, this is a weak enough explanation anyway...

  • Randyd (unregistered)
    Jake Vinson:

    Let's get things started with Michael, who shows us the easy way to calculate radii!

    intRadius = (int)0.5 + radius;

    I've seen this one alot - like some other posters - it's a good way to round up (if you get the parens right...)

    Jake Vinson:
     

    Ricky H.'s find speaks for itself.

    if b = b then
      b = true
    end if

    at first i thought... could this be some way of encoding a truth table? then i thought... WTF?  b should always = b.  Although i had to add the line k=k; into a program once to make it work... so maybe a funky compiler issue...

    Jake Vinson:
      

    P. C. apparently inherited code originally written by an evil genius from deep inside his volcano headquarters.

    @{$gst}{keys %{$rec}} = values %{$rec};  # muhahahaha

    I can see this happening.  The guy came up with a nice line of code that no mere hack would conjure...  he was proud of it. and the comment means: don't change this unless you know what you are doing.

     

  • Whiskey Tango Foxtrot? Over. (at work) (unregistered) in reply to kuroshin
    kuroshin:
    Jake Vinson:

    Let's get things started with Michael, who shows us the easy way to calculate radii!

    intRadius = (int)0.5 + radius;

    Looks like this is from Javascript.

    radius is some string and to get this value into an integer, well one hack was to add 0 to it.

    Not elegant though.

     Actually, operator precedence would cause the 0.5 to be cast to an int, yielding a value of 0, which would then be added to radius.

  • Whiskey Tango Foxtrot? Over. (at work) (unregistered) in reply to kuroshin
    kuroshin:
    Jake Vinson:

    Let's get things started with Michael, who shows us the easy way to calculate radii!

    intRadius = (int)0.5 + radius;

    Looks like this is from Javascript.

    radius is some string and to get this value into an integer, well one hack was to add 0 to it.

    Not elegant though.

     Actually, operator precedence would cause the 0.5 to be cast to an int, yielding a value of 0, which would then be added to radius.

  • Rich (unregistered) in reply to Jimbo

    No, it used the assignment (=) and not the comparison (==)

     b=b returns b. If b is false, the if doesn't execute and returns b (which is false).

     
    This is language dependent of course but it looks C stylee to me.
     

  • Rich (unregistered) in reply to Rich

    Crap, it isn't C style is it? I think I have code blindness.

     

    Rich 

  • (cs) in reply to rmr
    rmr:
    Jake Vinson:

    Ricky H.'s find speaks for itself.

    if b = b then
    b = true
    end if 

    Looks like the "poor man's conditional breakpoint" again.

    Any btw, I really like the earlier post time of the wtf.  Reading it after lunch is great!

     

    But it isn't this time! It's like a poor-man's conditional breakpoint that's broken! It will always fire, so it's not any more helpful than just 'b = true'.

     

    Or maybe it used to be the real poor man's conditional breakpoint, and has gradually morphed... 

     

    (Or maybe it's as Rich says and in a language where = in an if still does assignment. But given that it looks like VB... I'm betting not) 

  • Peter Bailey (unregistered) in reply to kuroshin
    kuroshin:

    Looks like this is from Javascript.

    radius is some string and to get this value into an integer, well one hack was to add 0 to it.

    Not elegant though.

    I believe you are right.  There are some nasty rounding errors that crop up in JavaScript arithmetic.  Something to do with hexadecimal representation of floats. 

    Of course, at the same time, I don't think you can last like that in JavaScript.  Anyway, I suppose the same rounding issues could occur in other languages.
     

  • Whiskey Tango Foxtrot? Over. (at work) (unregistered) in reply to Nachoo
    Nachoo:

    Three lefts are not, in fact, a right, as Chris C. shows.

    1000 GOTO 1002
    1001 GOTO 1010
    1002 GOTO 1001
     
    I dont get it. Please help me.... maybe it is so clear to see that I dont see it.

    Think of it as a Choose Your Own Adventure (tm) book:

    .... Bob is about to fire his gun!
    If you decide to dodge left, turn to page 1000.
    If you decide to dodge right, turn to page 1050.

    Page 1000
    Bob fires his gun just as you dodge left.
    Turn to page 1002 to find out if the bullet his you!

    Page 1002
    The bullet hits you!!
    Turn to page 1010 to find out if you live or die!

    Page 1010
    Whoops, the bullet killed you.
    The End.

  • anonymous (unregistered) in reply to Jimbo

    Anonymous:
    Note: If b=false then would come out of that equation equal to true.  The if... then is completley unneeded.  Now what the poor guy was meaning to do is a whole different matter.

     We need more information to conclude that something is wrong.
    For example, we don't know what the data type of b is: if b can be "null", then (except in a few strange Microsoft worlds), b = b will return false.

    To even claim this much, I'm making assumptions about the nature of "=".  Like I said at the beginning, we need more information before we can start laughing at this one.

  • Whiskey Tango Foxtrot? Over. (at work) (unregistered) in reply to Whiskey Tango Foxtrot? Over. (at work)

    Crap, I messed up the sequence! 

     

    captcha: whiskey. :D

  • bob the dingo (unregistered) in reply to anonymous

    no, no i'm pretty sure we can laugh at this now...

  • Octo (unregistered)
    <code>BYTE buffer[SIZE_2048];  /* data buffer 1024 bytes long */</code>
     
    We do live in a world of multi-byte character sets these days... the comment should have read "1024 characters" instead of bytes, but the code might well be valid.
  • (cs) in reply to Octo
    Anonymous:
    BYTE buffer[SIZE_2048];  /* data buffer 1024 bytes long */
     
    We do live in a world of multi-byte character sets these days... the comment should have read "1024 characters" instead of bytes, but the code might well be valid.

    Then in my opinion it's still a WTF because the datatype is wrong.
     

  • Who wants to know (unregistered) in reply to BradC

    Actually, there ARE a lot of 360 day year apps.

     Steve

  • (cs) in reply to Jimbo

    Anonymous:
    Note: If b=false then would come out of that equation equal to true.  The if... then is completley unneeded.  Now what the poor guy was meaning to do is a whole different matter.

    Wrong, it would come out false. The value of an assignment statement is equal to the value that was assigned. Thus, (b = false) evaluates to false, and b would not come out true because that part would be skipped.

  • Unklegwar (unregistered)
    Jake Vinson:

    Submitted anonymously, the code not included in this is sure to offend all of the other colors and creeds.

    private static Language Italian = new Language("Italian"); // linguini-eating mobsters

     

     

    I wanna see the rest of the constructor calls in the Stereotype Factory!!!!

     

     

  • (cs) in reply to Peter Bailey
    Anonymous:

    There are some nasty rounding errors that crop up in JavaScript arithmetic.  Something to do with hexadecimal representation of floats. 

    Of course, at the same time, I don't think you can last like that in JavaScript.  Anyway, I suppose the same rounding issues could occur in other languages.
     

     Floating-point math is inexact on nearly every architecture due to the binary representation. It looks like C code to me though, and it looks like the programmer is trying to round off a float, not just cast it. However, some parentheses were forgotten. I think the real WTF is that whoever sent that in thinks it's a WTF. 
     

  • (cs) in reply to Octo
    Anonymous:
    <code>BYTE buffer[SIZE_2048];  /* data buffer 1024 bytes long */</code>
    We do live in a world of multi-byte character sets these days... the comment should have read "1024 characters" instead of bytes, but the code might well be valid.

    I doubt it's characters - the name of the struct (disk_request) suggests that it's pretty low-level code.

     Also, no-one seems to have commented on the bizarreness of

    #define SIZE_2048 2048
    .  You guys are going soft. :-(
     

  • (cs) in reply to Whiskey Tango Foxtrot? Over. (at work)
    Anonymous:
    Nachoo:

    Three lefts are not, in fact, a right, as Chris C. shows.

    1000 GOTO 1002
    1001 GOTO 1010
    1002 GOTO 1001
     
    I dont get it. Please help me.... maybe it is so clear to see that I dont see it.

    Think of it as a Choose Your Own Adventure (tm) book:

    .... Bob is about to fire his gun!
    If you decide to dodge left, turn to page 1000.
    If you decide to dodge right, turn to page 1050.

    Page 1000
    Bob fires his gun just as you dodge left.
    Turn to page 1002 to find out if the bullet his you!

    Page 1002
    The bullet hits you!!
    Turn to page 1010 to find out if you live or die!

    Page 1010
    Whoops, the bullet killed you.
    The End.

     

    Also know as "spaghetti code"

    {no offense intended to the linguini-eating mobsters}

  • Muhahahaha (unregistered)

    I wrote the "# muhahahaha" line two companies ago, and like "Irrelevant" the first thing I thought when I saw it again was that it had unnecessary braces, and in my defense, Bob probably made me keep them.  I believe at the time it replaced a much larger and clunkier chunk of code, hence the evil laughter from my volcanic headquarters.  Naturally I know who P.C. is and I'll be dropping him a line.  Good times, good times :).

  • Megalomaniacs4u (unregistered) in reply to Irrelevant
    Irrelevant:
    Alex:
    @{$gst}{keys %{$rec}} = values %{$rec}; # muhahahaha

    Is it bad that I understood this instantly?

    I actually did benchmarks for methods of combining two hashes in perl, and this method seems to be significantly faster than any others I tried. I think it looks a lot nicer without all those optional braces, tho:

    @$gst{keys %$rec} = values %$rec;

    And as for the comment... well, I'm gonna have to confess to using similar comments myself. Code can be evil-genious-y without being inappropriate for serious projects, IMO.

    Well quite. As perl code goes this is rather sane, readable even with all the curlies, I've seen & written far more evil code in the last ten years. The only WTF was why was this included?

    As for the comment I write similar things all the time, and I now several perl mongers with far more evil commenting schemes.

     

    Captcha: STFU (oh if I must.. ;-)

     

  • (cs) in reply to mkb
    mkb:

    Anonymous:
    Note: If b=false then would come out of that equation equal to true.  The if... then is completley unneeded.  Now what the poor guy was meaning to do is a whole different matter.

    Wrong, it would come out false. The value of an assignment statement is equal to the value that was assigned. Thus, (b = false) evaluates to false, and b would not come out true because that part would be skipped.

     

    What language are you assuming it is?

    It looks like Visual Basic to me, which means that b=b is a comparison, not assignment.

     

  • AnonyMonk (unregistered) in reply to Irrelevant

    "Is it bad that I understood this instantly?" It's only bad, since that code isn't legal perl code. You can assign to an array of hash keys that way, you just have to do something like "%bighash = (%hash1,%hash2);"

  • Marcos (unregistered) in reply to Megalomaniacs4u

    I agree, the Perl should be instantly grokkable to anyone who's done any serious programming with references in Perl5.  I do think it's clearer without the braces, though.  For even greater clarity, when performance wasn't at a premium I'd probably go with this less-efficient but (to me) easier to read version:
     

    # merge %$rec into %$gst
    %$gst = %$gst, %$rec;

     

     

  • Marcos (unregistered) in reply to Marcos

    Huh.  Where'd my parentheses go?  That should be this:

    %$gst = (%$gst, %$rec);


     

     

  • EvilTeach (unregistered) in reply to Jon Sagara

    We have clients that measure quarters in groups of {4 week, 4 week, 5 week}

     4 quarters * 13 weeks = 52 weeks = 364 days.

     
    Hence their calendar drifts at least 1 day a year, and 2 on leap years,

    and every 6 years so so, we are required to make program changes to bring their calendar back in line

    with the 365/366 day calendar.

     

     

  • Rich (unregistered) in reply to anonymous
    Anonymous:

    For example, we don't know what the data type of b is: if b can be "null", then (except in a few strange Microsoft worlds), b = b will return false.

     

    Not necessarily. (Though it will act as if false for the "if")

     mysql> select null=null;
    +-----------+
    | null=null |
    +-----------+
    |      NULL |
    +-----------+
    1 row in set (0.00 sec)

     

    Captcha: null (amusingly enough) 

  • (cs) in reply to mkb
    mkb:
    Anonymous:

    There are some nasty rounding errors that crop up in JavaScript arithmetic.  Something to do with hexadecimal representation of floats. 

    Of course, at the same time, I don't think you can last like that in JavaScript.  Anyway, I suppose the same rounding issues could occur in other languages.
     

     Floating-point math is inexact on nearly every architecture due to the binary representation. It looks like C code to me though, and it looks like the programmer is trying to round off a float, not just cast it. However, some parentheses were forgotten. I think the real WTF is that whoever sent that in thinks it's a WTF. 
     

    Floating point math is inexact on all architectures (provided you use fixed-length mantissa and exponent), because it was designed that way. It's just a quick, memory-efficiant but inaccurate way to represent fractions using a logarithmic scale.

  • Your Name (unregistered) in reply to R.Flowers
    R.Flowers:
    Jake Vinson:

    Three lefts are not, in fact, a right, as Chris C. shows.

    1000 GOTO 1002
    1001 GOTO 1010
    1002 GOTO 1001

     

    How old are some of these?

    I'll step up and tell you that I cut my programming teeth on BASIC with line numbers. I'll also offer a guess as to how this ended up in the wild.

    Depending on the machine and the BASIC variant, jumping over a line of code might be easier than 'commenting it out.' Some of those old built-in editors were onery, and it was much easier to use a GOTO to jump over a suspect line. (Line 1002 might have just been something like 1002 REM - DEBUGGING.) Then, after that line was checked, the programmer, again avoiding the editor, just changed line 1002 to jump to the original line. Why not 1010? Hey, this is a weak enough explanation anyway...

    I was thinking this might be an automated translation from FORTRAN, which for some dumb reason assumed every GOTO was a computed GOTO.

  • mugs (unregistered)
    Jake Vinson:

    Ricky H.'s find speaks for itself.

    if b = b then
    b = true
    end if

     

     Most of you are assuming that this one is written in a language that uses = as both the comparison operator and assignment operator.  If that is not the case, then this is really just the same as setting b = true if b has a value that evaluates to true (like 1). 

     

  • CH (unregistered)
    Jake Vinson:

    Submitted anonymously, the code not included in this is sure to offend all of the other colors and creeds.

    private static Language Italian = new Language("Italian"); // linguini-eating mobsters

     

     Another possible wtf is shouldn't this be marked as final? Or are they leaving it open for change in case Italy is taken over by Martians while the program is running?
  • Shadowman (unregistered) in reply to Rich
    Anonymous:

    No, it used the assignment (=) and not the comparison (==)

     b=b returns b. If b is false, the if doesn't execute and returns b (which is false).

     
    This is language dependent of course but it looks C stylee to me.
     

    It doesn't look C stylee to me... the conditional isn't in parenthesese (parenthasees? parenthesees? parentheseas? er..curved braces.),  and the keyword "then" is used.

     

Leave a comment on “Coded Smorgasboard: Muhahahahaha”

Log In or post as a guest

Replying to comment #95105:

« Return to Article