• Zlodo (unregistered)
    public static void checkRational(int rational)
    {
    int myRational = rational;

    try
    {

    }
    catch (Exception ex)
    {
    checkRational(myRational);
    }
    }

     Ok, I have no idea there. You can perceive a reason, however ridiculous for stupid pieces of code to exist, but this one just doesn't makes any sense.

    It's not a poor man's breakpoint, it's not merely a left-over unimplemented function, it just doesn't make sense. Perhaps the original author was drunk or tired, or it is the result of a copy/paste went wrong?

    Perhaps it uses a weird compiler where the preprocessor allows to create a macro whose name is a whitespace?

  • MGS (unregistered)
    Jake Vinson:
    /* note, system uses 360 days in a year, not 365 */

     

    I'd just like to point out that just because something is in common usage, doesn't mean it's not a serious WTF.

     On the other hand, perhaps the real WTF is that there are 365.2425 days in a year.
     

  • (cs) in reply to MGS
    Anonymous:
    Jake Vinson:
    /* note, system uses 360 days in a year, not 365 */

     

    I'd just like to point out that just because something is in common usage, doesn't mean it's not a serious WTF.

     On the other hand, perhaps the real WTF is that there are 365.2425 days in a year.
     

     

    Absolutely, and we here at the 'Mass. Organization of Radically Organizing Numbers and Space' are hard at work on the solution.  Our current plan is to use rocket power to push the Earth into a slightly closer and faster orbit around the sun to bring us to an even 360 day year.  After that we will begin work on that pesky PI number.
     

  • (cs) in reply to smbell
    smbell:
    Anonymous:
    Jake Vinson:
    /* note, system uses 360 days in a year, not 365 */

     

    I'd just like to point out that just because something is in common usage, doesn't mean it's not a serious WTF.

     On the other hand, perhaps the real WTF is that there are 365.2425 days in a year.
     

     

    Absolutely, and we here at the 'Mass. Organization of Radically Organizing Numbers and Space' are hard at work on the solution.  Our current plan is to use rocket power to push the Earth into a slightly closer and faster orbit around the sun to bring us to an even 360 day year.  After that we will begin work on that pesky PI number.
     

    I believe that group has already taken up the matter of "that pesky number". ;-)

     

    http://www.straightdope.com/classics/a3_341.html 

  • Artemus Harper (unregistered) in reply to Shadowman

    FYI, a possible implementation in java of Double.isNaN(double d):

     

    public boolean isNaN(double d)

    {

       return d != d;

    }

     Just to show that there are cases of testing to see if something is equal to itself.

  • s (unregistered) in reply to Artemus Harper
    Anonymous:

    FYI, a possible implementation in java of Double.isNaN(double d):

     

    public boolean isNaN(double d)

    {

       return d != d;

    }

     Just to show that there are cases of testing to see if something is equal to itself.

    if b = b then
    b = true
    end if

    So how would this apply to  a bool-type variable? 

  • (cs) in reply to Disgruntled DBA
    Disgruntled DBA:
    smbell:
    Anonymous:
    Jake Vinson:
    /* note, system uses 360 days in a year, not 365 */

     

    I'd just like to point out that just because something is in common usage, doesn't mean it's not a serious WTF.

     On the other hand, perhaps the real WTF is that there are 365.2425 days in a year.
     

     

     

    Absolutely, and we here at the 'Mass. Organization of Radically Organizing Numbers and Space' are hard at work on the solution.  Our current plan is to use rocket power to push the Earth into a slightly closer and faster orbit around the sun to bring us to an even 360 day year.  After that we will begin work on that pesky PI number.
     

    I believe that group has already taken up the matter of "that pesky number". ;-)

     

    http://www.straightdope.com/classics/a3_341.html 

    I'm offended.  We here at the 'Mass. Organization of Radically Organizing Numbers and Space' are working on REAL solutions!!!1one!  Fixing PI will require small 'tweaks' to space-time to correct the problems of 2D and 3D geometry.  Worry not, our capable scientists have the problem well under control.

  • mustache (unregistered)
    Jake Vinson:

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

    1000 GOTO 1002
    1001 GOTO 1010
    1002 GOTO 1001
    What's wrong with a little loop-the-loop?  Should keep the Little Man entertained. 
  • (cs) in reply to Zlodo
    Anonymous:
    public static void checkRational(int rational)
    {
    int myRational = rational;

    try
    {

    }
    catch (Exception ex)
    {
    checkRational(myRational);
    }
    }

     Ok, I have no idea there. You can perceive a reason, however ridiculous for stupid pieces of code to exist, but this one just doesn't makes any sense.

    It's not a poor man's breakpoint, it's not merely a left-over unimplemented function, it just doesn't make sense. Perhaps the original author was drunk or tired, or it is the result of a copy/paste went wrong?

    Perhaps it uses a weird compiler where the preprocessor allows to create a macro whose name is a whitespace?

     ... I got nothing.

    I do notice that, if the whitespace does throw an error, the catch block creates an infinite recursion.

     

  • (cs) in reply to Artemus Harper
    Anonymous:

    FYI, a possible implementation in java of Double.isNaN(double d):

     

    public boolean isNaN(double d)

    {

       return d != d;

    }

     Just to show that there are cases of testing to see if something is equal to itself.

    ???  While there is no garuntee that any two NaN's in Java will be equal there is also no garuntee that any two NaN's will be different.   However that only applies to two different NaN's, the code you posted will always return false.

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

    FYI, a possible implementation in java of Double.isNaN(double d):

     

    public boolean isNaN(double d)

    {

       return d != d;

    }

     Just to show that there are cases of testing to see if something is equal to itself.

    ???  While there is no garuntee that any two NaN's in Java will be equal there is also no garuntee that any two NaN's will be different.   However that only applies to two different NaN's, the code you posted will always return false.

    My bad, I was testing Infinity rather than NaN.  I retract my earlier statement.  *walks away in shame*
     

  • paula (unregistered) in reply to s
    Anonymous:
    Anonymous:

    FYI, a possible implementation in java of Double.isNaN(double d):

     

    public boolean isNaN(double d)

    {

       return d != d;

    }

     Just to show that there are cases of testing to see if something is equal to itself.

    if b = b then
    b = true
    end if

    So how would this apply to  a bool-type variable? 

    Isn't it obvious? He is testing for filenotfound.
     

  • (cs) in reply to AnonyMonk
    AnonyMonk:
    "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);"
    >perl -Wce"@{$gst}{keys %{$rec}} = values %{$rec};"
    Name "main::gst" used only once: possible typo at -e line 1.
    -e syntax OK

    Please turn in your Monk-card -- hash slices've been around since before perl5. (Yes, I checked the no-curlies version too.)

  • (cs)
    Jake Vinson:

    Ricky H.'s find speaks for itself.

    if b = b then
    b = true
    end if

    Looks quite sensible to me. If b is NaN or b IS NULL, the assignment will be skipped. On the other hand, if b equals true, false, "brillant" or FileNotFound, it will be set to true.

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

    WTF? I've used C, C++, Java and C# and this does not look the slightest bit "C stylee" (sic) to me. It looks more like Basic.

    Of course, the real WTF is that Basic uses the same symbol for assignment and equality comparison.

  • Rich (unregistered) in reply to Zlodo
    Anonymous:

    uses a weird compiler where the preprocessor allows to create a macro whose name is a whitespace?

     

    Embedded <a href="http://en.wikipedia.org/wiki/Whitespace_%28programming_language%29">Whitespace</a>?

     

    Rich 

  • Anonymous (unregistered) in reply to AnonyMonk

    Anonymous:
    "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);"

    Re-read the "Slices" section of the perldata manpage. 

  • Rich (unregistered) in reply to smbell
    smbell:

    I'm offended.  We here at the 'Mass. Organization of Radically Organizing Numbers and Space' are working on REAL solutions!!!1one!  Fixing PI will require small 'tweaks' to space-time to correct the problems of 2D and 3D geometry.  Worry not, our capable scientists have the problem well under control.

     PI is a mathematical construct that just happens to bear relation to geometry in Euclidian space. You can fiddle with space-time all you want and it won't change the value of PI.

     You're going to need to dig in and change mathematics itself.

     

    Rich

     

  • Anonymous (unregistered) in reply to Rich

    Actually no in VB = does both assignment and comparison based on context.

    Comparison:

    if b = 1 then ... end

    Assignment:

    b = 1

    Lame, but that's Basic for you. :)

  • Rich (unregistered) in reply to Alexis de Torquemada
    Alexis de Torquemada:

    WTF? I've used C, C++, Java and C# and this does not look the slightest bit "C stylee" (sic) to me. It looks more like Basic.

    Sorry, I already beat you to correcting myself. 

    Alexis de Torquemada:

    Of course, the real WTF is that Basic uses the same symbol for assignment and equality comparison.

     Equally as wtf is that other languages use the equality operator (=) for assignment then to test equality end up using things like "=="

     Rich
     

     

     

  • (cs) in reply to smbell
    smbell:

    After that we will begin work on that pesky PI number.

    Not necessary. Any mathematician knows that Pi = 3 for sufficiently small values of Pi and sufficiently large values of 3.

    GWB: We ought to make the Pi higher.

    AdT: No, dumbass, we ought to make it lower!

  • (cs) in reply to Rich
    Anonymous:

    Sorry, I already beat you to correcting myself. 

    My sincerest apologies! 

    Anonymous:

    Equally as wtf is that other languages use the equality operator (=) for assignment then to test equality end up using things like "=="

    Yes, = is the mathematical equality operator, but it is also used to "fix" variables to certain values, which is quite similar to assignment in C (though more similar to assignment in functional programming languages). I think the decision for == and = was wrong because Pascal's = and := mirrors the similarities and dissimilarities to mathematical concepts more closely. But in any case that's better than using the same symbol for entirely different purposes depending on the type of expression it is used in.

    In C, "a = b" is always interpreted in the same way no matter where you use it, and the same goes for "a == b" (assuming no outside operator with higher precedence interferes). In Basic, "a = b" can at one time mean one thing, and at another time mean another. I find this far more irritating than using == for comparison.

     

  • (cs) in reply to Artemus Harper

    Ignoring the problem of this being based on a property of NaN which is not guarunted (as noted elsewhere), even if it were, it would have a problem, as the operator== (and therefore operator!=) would almost out of necessity have to call Double.isNaN, forcing infinite recursion

  • (cs) in reply to JamesCurran

    Just to clear a few things up here is a copy of the actual implemenation of Double.isNaN(double)

    
        /**
         * Returns true if the specified number is a
         * Not-a-Number (NaN) value, false otherwise.
         *
         * @param   v   the value to be tested.
         * @return  true if the value of the argument is NaN;
         *          false otherwise.
         */
        static public boolean isNaN(double v) {
    	return (v != v);
        }
    
  • (cs) in reply to smbell
    smbell:

    ???  While there is no garuntee that any two NaN's in Java will be equal there is also no garuntee that any two NaN's will be different.   However that only applies to two different NaN's, the code you posted will always return false.

    Actually, there is such a guarantee.  From the Java Language Specification:

    "The equality operator == returns false if either operand is NaN, and the inequality operator != returns true if either operand is NaN."

    Regardless of the bit pattern, no NaN value ever equals another NaN value.

  • (cs) in reply to Unklegwar
    Unklegwar:
    I wanna see the rest of the constructor calls in the Stereotype Factory!!!!
    // TODO: do we even need these? I thought everyone spoke EN-US these days...
    private static Language Russian = new Language("Russian"); // vodka-drinking mobsters
    private static Language French = new Language("Freedom"); // cheese-eating surrender-monkeys
    private static Language UKEnglish = new Language("English-UK"); // Hugh Grant
  • (cs) in reply to JamesCurran

    JamesCurran:
    Ignoring the problem of this being based on a property of NaN which is not guarunted (as noted elsewhere),

    This is required by the Java language spec (the guy who first brought up NaN used a Java example, but this behaviour is also required by IEEE-754, which most progamming languages follow).

    even if it were, it would have a problem, as the operator== (and therefore operator!=) would almost out of necessity have to call Double.isNaN, forcing infinite recursion

    More likely it's implemented using the CPU instruction for floating-point comparison, which IIRC on most CPUs handles NaNs automatically (and on architectures where it doesn't, I expect the JIT would generate specialised code, or possibly a call to a built-in routine, but I highly doubt it would call a method written in Java).
  • cratermoon (unregistered) in reply to iwpg

    Reading the daily WTF regularly reminds me of the woeful lack of understanding of floating point issues and the conventions of the financial world among programmers.  By that I don't mean just the coders whose work is displayed here for our enjoyment, but the readers and submitters, too.  The domains and implementations of some things in code just result in unintuitive expressions sometimes, either to match the conventions of the users, or to get around limitations in computers.

     It probably wouldn't bother me so much except for those times when teammates who didn't bother to learn the decided my code was obviously wrong and changed it to something "right".  And the time the whole team ignored my advice (I was consulting) about not using Java float for money, and spent the better part of three months chasing bugs in calculations that were off by a penny, only to find that after multiple convoluted "fixes" to handle various special cases they still got the same bugs, or not, depending on the numbers input.
     

  • John (unregistered) in reply to anonymous
    Anonymous:

    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.

    "It depends what the definition of 'is' is."

  • daen (unregistered)
     
    /* note, system uses 360 days in a year, not 365 */
    Well, to be´fair some US and international fixed income markets use a 360 day calendar for calculating accrued interest (http://www.answers.com/topic/accrued-interest) so it's not realllllly a WTF ... except insofar as financial markets themselves are a WTF ... :-)
  • Cheong (unregistered)
    Jake Vinson:

    Ricky H.'s find speaks for itself.

    if b = b then
    b = true
    end if

     

    Actually, I've seen something similarly nonsense in a source that has been converted from assembly language to C++... the statement has been used to set certain CPU flags in the origional code, but somehow got it's way into the converted C++ one. 

    Captcha: paste. How I love copy and paste try-and-tested code everywhere! 

  • (cs) in reply to kmactane
    kmactane:
    /* note, system uses 360 days in a year, not 365 */

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

    falling from mars? or you never heard how some financial companies compute interest for days when a yearly interest rate was contracted? wake up please - this is not a wtf at all

     

    Edit: I should have read the entire thread first I guess....

  • mike (unregistered) in reply to Rich

    im fairly sure c style would look more like

     

    if (b == b) {b = true;}

     

    that snippet looks like basic 

  • Sam (unregistered) in reply to kmactane

    This calendar is not Babylonian. It caled 30/360 and is commonly used (at least in Europe) for banking and finance applications. In this calendar very month has 30 days and therefore a year has 360. This probably made calculating interest a whole lot easier when COBOL was not yet around.

    Of course there is a slight advantage of 5-6 days where the bank doesn't have to pay interest to their suppliers. Using such a calendar nowadays is just ridiculous and only a means of ripping off customers. When dealing with debtors the effort of maintaining a 365/366 day calendar suddenly doesn't seem to be that much of an issue.

  • Nachoo (unregistered) in reply to Cyan
    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.

    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

     

    For I shall thank ye.
     

  • Paul (unregistered)
    Surely the WTF is in the description of this code.  An exception will not cause recusion as no code is executed in the try block.  
    It's not even possible to pass white space into  this function as it is already strongly typed!  
     
    public static void checkRational(int rational)
    

    { int myRational = rational;

    try {

    } catch (Exception ex) { checkRational(myRational); } }

     
     

  • (cs)
    Jake Vinson:

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

    1000 GOTO 1002
    1001 GOTO 1010
    1002 GOTO 1001

     

    This looks perfectly fine to me. Apparently no one here ever heard of out of order execution.

  • Martijn (unregistered) in reply to Sam
    Anonymous:

    This calendar is not Babylonian. It caled 30/360 and is commonly used (at least in Europe) for banking and finance applications. In this calendar very month has 30 days and therefore a year has 360. This probably made calculating interest a whole lot easier when COBOL was not yet around.

    Of course there is a slight advantage of 5-6 days where the bank doesn't have to pay interest to their suppliers. Using such a calendar nowadays is just ridiculous and only a means of ripping off customers. When dealing with debtors the effort of maintaining a 365/366 day calendar suddenly doesn't seem to be that much of an issue.

    In fact, this 360-days-a-year things isn't even technically; it's pretty old and pre-dates computers. It's rather normal here in europe (and to my knowledge, the financial world in general) and is used for a lot of things, not to mention a lot of (international) regulation which makes unilaterally switching to another calender system rather... adventurous.

    Actually, most banks nowadays, DO compensate interest for the full number of 365/366 days a year, they mainly use 360 days internally. Obviously it doesn't make any difference whatsoever, because rates are based on 360 days as well. Get 3.60/360 % per day or 3.6525/365.25 % per day; it doesn't really make a difference.

  • DiRadical (unregistered) in reply to Jon Sagara
    Jon Sagara:

    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.

    I think you are right. A bank year has 360 days and I think it is used to pay interest.

    They probably keep 5 days for them selves, the thieving b*stards

  • HardCoder (unregistered) in reply to mike
    Anonymous:

    im fairly sure c style would look more like

     

    if (b == b) {b = true;}

     

    that snippet looks like basic 

     

    This is by far not clever enough. Take this:

    b = (b == b ? true : false) ;

    Remember, C is about doing things you can't do in Basic. 

  • Aigars Grins (unregistered) in reply to rmr

    Or it could be a case where b sometimes is set to NULL and the test "NULL = NULL" yields NULL which is interpreted as False. The code above could then pass as a way of converting any non-NULL value to True, i.e. "b = not IsNull(b)".

  • Baldvin (unregistered) in reply to rmr

    I am not sure. It can be since he found lots of  variable == true  tests in the code, and only wanted to assure that if the logical value of it is true, then it is actually equals true...

     

  • Baldvin (unregistered) in reply to Baldvin

    Sorry, I wasn't careful enough, my last post is a mistake.

  • An apprentice (unregistered) in reply to Alexis de Torquemada
    Alexis de Torquemada:

    In C, "a = b" is always interpreted in the same way no matter where you use it, and the same goes for "a == b" (assuming no outside operator with higher precedence interferes). In Basic, "a = b" can at one time mean one thing, and at another time mean another. I find this far more irritating than using == for comparison.

    True, but C isn't consistent either. For example, *foo(bar+37) and foo*(bar+37) have wildly different semantics for * and (). So 'being always interpreted in the same way' isn't terribly important.

    </a pointless rant> 

  • Thuenor (unregistered) in reply to DiRadical
    Anonymous:
    Jon Sagara:

    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.

    I think you are right. A bank year has 360 days and I think it is used to pay interest.

    They probably keep 5 days for them selves, the thieving b*stards



    Not quite. Banks give out loans that bear interest act[ual]/360, meaning you pay 5-6 days extra interest each year. Interest on savings is usually either 360/360 or act/act.
  • anonymous (unregistered) in reply to Rich
    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) 

     

    You're right- I should have said:  b = b will not return true.

  • anonymous (unregistered) in reply to Rich
    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) 

     

    You're right- I should have said:  b = b will not return true.

  • m0ffx (unregistered) in reply to smbell

    smbell:
    Absolutely, and we here at the 'Mass. Organization of Radically Organizing Numbers and Space' are hard at work on the solution.  Our current plan is to use rocket power to push the Earth into a slightly closer and faster orbit around the sun to bring us to an even 360 day year.  After that we will begin work on that pesky PI number.

    Your group needs to redo its physics calculations. It will take a lot less rocket power to simply slow the Earth's spin so as to make 360 days a year. Plus that has the advantages of not contributing to global warming (it should actually cool us), andthe 24.35 hourd day that results is a better match to our own biological clock (which is about 25 hours).

  • Monkios (unregistered)

     

    Ricky H.'s find speaks for itself.

    if b = b then
    b = true
    end if
     b = ( b = b ) 
  • (cs) in reply to Paul
    Paul:
    Surely the WTF is in the description of this code. An exception will not cause recusion as no code is executed in the try block.
    It's not even possible to pass white space into  this function as it is already strongly typed!  

     

    I believe his comment about white space throwing an exception refers to the single line of white space in the try block, which would obviously never throw anything, hence WTF are you doing checking it?

    My only possible explanation is that there used to be something there and it has since been removed, without removing everything else.

    Of course, that still doesn't explain why you would recurse on error. (If it doesn't work the first time, try, try again.)

     
    Edit: The real WTF is that the Quick Reply button on a post doesn't allow for quoting of the original post!

  • (cs)
    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

    Apparently this is not an uncommon thing to comment...

    muahahaha
     

Leave a comment on “Coded Smorgasboard: Muhahahahaha”

Log In or post as a guest

Replying to comment #95185:

« Return to Article