• hoens (unregistered)

    The real WTF is the tripple post....

  • EV (unregistered)

    I competed in NWERC last sunday... See: http://www.csc.kth.se/contest/nwerc/2006/

    The judge's solutions were posted today... I saw the following line in the code:

    int INF=99999999 

  • (cs) in reply to EV

    Defining infinity as a large but finite number is possibly the least wtfey thing there. It seems quite reasonable that you might be modelling some situtation where once a value gets large enough, it might as well be infinite, or that you might want to approximate an infinite process, e.g. a series summation or an iteration, by a finite one.

  • Igor (unregistered)

    Nikita Zhuk is definitely a "he", not "she"

  • Rob G! (unregistered)

    I would have opted for "DrStrangelove", but I guess "DickBagMcButtMunch" works too..... But I can't even imagine writing DickBagMcButtMunch in code, Even though I consider myself creative......

    rob

    Captcha = random,  as in this programmer

  • (cs) in reply to m0ffx

    m0ffx:
    Defining infinity as a large but finite number is possibly the least wtfey thing there. It seems quite reasonable that you might be modelling some situtation where once a value gets large enough, it might as well be infinite, or that you might want to approximate an infinite process, e.g. a series summation or an iteration, by a finite one.

    Exactly right. The SCPI standard (Standard Commands for Programmable Instruments) used in the test and measurement industry defines infinity as 9.9E37. To quote the standard:

    The numeric values for positive and negative infinity were chosen so that they fit into a 32-bit IEEE 754 floating point number. This allows easy implementation using standard tools in all popular languages and operating systems. Note that this does not limit the numeric resolution. These values are larger than any quantities used or anticipated in instruments.
     
  • Vagary (unregistered)

    I know absolutely no Chinese, but my research says:

    So the function translates to:

    /*Added by Jiang W */
    void compute(int hello)
    {
    int temp = 0;
    // temp = 3 /*erase by Li K */
    temp = 3;
    return;
    }

    Obviously just testing out the language - a HelloWorld sort of thing.

  • An apprentice (unregistered)
    Alex Papadimoulis:
    if (Math.max(1, 2) == 2) return;

    Don't ever trust your libraries. Common paranoia or defensive programming taken to the extreme?

  • (cs) in reply to RogerC
    Alex Papadimoulis:

    Oscar found this during a recent, and apparently much needed, clean up of the codebase for an application. Good for when the number line reverses itself I suppose?

    if (Math.max(1, 2) == 2) return; 

    [snip] 

    I guess in Ryan Patterson's company, use of equipment changes the basic laws of mathematics?

    IF 0 > 0
    BEGIN
    SELECT 'Equipment is in use'
    RETURN
    END

    Maybe both of those were slightly "creative" ways to "temporarily" comment out the block/rest of the function?  Perhaps the JavaScript one already had /* */ comments, so the programmer couldn't have used those (since they don't nest), and maybe that SQL dialect didn't have block comments at all - and both programmers were too lazy to figure out how to make their editors add end-of-line comments to each line (that's not much of an excuse with the SQL one, since it's so short, but that's hardly the worst thing that's ever been on this site).

    RogerC:

    Exactly right. The SCPI standard (Standard Commands for Programmable Instruments) used in the test and measurement industry defines infinity as 9.9E37. To quote the standard:

    The numeric values for positive and negative infinity were chosen so that they fit into a 32-bit IEEE 754 floating point number. This allows easy implementation using standard tools in all popular languages and operating systems. Note that this does not limit the numeric resolution. These values are larger than any quantities used or anticipated in instruments.

     

    In that case, the Real WTF is that they didn't use the infinities built into IEEE 754 in the first place.... (Well, OK, maybe they wanted to support systems that don't implement the full IEEE spec.) 

  • Dazed (unregistered) in reply to Igor
    Anonymous:
    Nikita Zhuk is definitely a "he", not "she"

    Based on what? That you are Nikita Zhuk? I know two Nikitas and they are both female.

  • jer (unregistered) in reply to EV
    Anonymous:

    I competed in NWERC last sunday... See: http://www.csc.kth.se/contest/nwerc/2006/

    The judge's solutions were posted today... I saw the following line in the code:

    int INF=99999999 

    How would you quantify an infinite value in a finite system? The best you can do is approximate it.

  • Huggie (unregistered)
    Alex Papadimoulis:
    private static final Logger logger 
    = Logger.getLogger("DickBagMcButtMunch");

    Ehl. Oh. Ehl. 

  • yazow (unregistered)
    Alex Papadimoulis:

    From A, I guess this just gives a whole new meaning to "Infinity Plus One" ...

    #define INFINITE	10000

     

    Not a WTF at all. Let say you are writing a simple router or something, you need some value that is agreed as "infinite" that can be counted up to for the max delay (that is smaller than the max of whatever data type you are using). Without the rest of the code it's hard to say it is a wtf when it is out of context. The one after baffles me though.. I can't think of a single time when I'd want ZERO to be -1.

  • mgsloan (unregistered)
    Alex Papadimoulis:

    I used above ASP.NET code. Problem is in " Rnd() "
    Rnd() value is changing everytime.

    What is the alternative for Rnd()?
    OR How will stop Rnd() value changes at everytime? 

     

    Perhaps they actually have a greater understanding, having prematurely grasped the concept of purely functional code?

  • Michael Buschbeck (unregistered) in reply to iwpg
    iwpg:
    Alex Papadimoulis:

    Oscar found this during a recent, and apparently much needed, clean up of the codebase for an application. Good for when the number line reverses itself I suppose?

    if (Math.max(1, 2) == 2) return;

    Maybe both of those were slightly "creative" ways to "temporarily" comment out the block/rest of the function?  Perhaps the JavaScript one already had /* */ comments, so the programmer couldn't have used those (since they don't nest), and maybe that SQL dialect didn't have block comments at all - and both programmers were too lazy to figure out how to make their editors add end-of-line comments to each line (that's not much of an excuse with the SQL one, since it's so short, but that's hardly the worst thing that's ever been on this site).

    Java, I'd say, not JavaScript; and the WTF-est part of it is probably the circuitous way of writing "true."

    I occasionally find myself adding "if (true) return;" to Java code I'm debugging in order to shortcut over the remainder of the method. In most other languages, I'd just write the equivalent of "return;", but Java, being its tiresome self, knows better than to let me have unreachable code in a method body without throwing a fatal compilation error.

    Not that Sun's "javac" would be clever enough to recognize that "if (true)" is, in effect, an unconditional branch, too. Hmm, maybe the original author of the quoted code did have a smarter "javac" implementation than Sun's... but then, debug code like this getting into production is just as much a WTF.

    (First post here.  I almost daren't press "Post" lest the "hotdog" in the captcha eat my formatting.)
  • (cs)

    From the Jan-Feb 1982 of Computer Gaming World (as discovered by Jaliya Jayawardena), here's how we used to patch games before that whole Internet thing was around ...

    From the days of yore, when readers of gaming magazines were usually able to code...

    That said, just last weekend I came across a cheap accounting tool that, in the print-out for the installation procedure, explained what to change a certain line of install.bat to, since they'd made a typo in one of the batch commands.

    In both cases, the one-line fix didn't merit the cost for distributing a new version. Thank goodness for the internet...

  • reinis (unregistered) in reply to Dazed

    Anonymous:
    Based on what? That you are Nikita Zhuk? I know two Nikitas and they are both female.

     ??? is a Russian surname, and ?????? is a male name in Russia.

  • reinis (unregistered) in reply to reinis

    reinis:
    ??? is a Russian surname, and ?????? is a male name in Russia.

    So, in Russia it's not a unisex name.

  • Kenton (unregistered)

    if (Math.max(1, 2) == 2) return;

    This was probably intended as an alternative to commenting out the rest of the method.  Java normally refuses to compile code that has blocks which can never be reached, so "return;", "if (true) return;", and even "if (0 == 0) return;" would not have worked.  You have to trick the compiler into thinking that it might be possible to skip the return.  You might want to do this if the code below couldn't be commented because it had /* */ comments in it already, or if you wanted the compiler to continue to typecheck the code even though it was not being used.

    Of course, code like this should never be checked in to source control; just used for temporary testing. 

    Captcha:  wtf
     

  • (cs) in reply to Kenton
    Anonymous:

    if (Math.max(1, 2) == 2) return;

    This was probably intended as an alternative to commenting out the rest of the method.  Java normally refuses to compile code that has blocks which can never be reached, so "return;", "if (true) return;", and even "if (0 == 0) return;" would not have worked. 

    Using "if (true) return;" is possible in Java (I use it sometimes myself) because the compiler does not check for constant expressions. However, my Java IDE's (IntelliJ IDEA) code inspections do give a warning about it, the same they do for "1 + 2 == 3" etc., so maybe the writer of that code wanted to avoid the warning by using an overly complicated expression.

  • Vasilij (unregistered) in reply to reinis
    Anonymous:

    reinis:
    ??? is a Russian surname, and ?????? is a male name in Russia.

    So, in Russia it's not a unisex name.

    Nope. Even if it was, the last name would be a giveaway, the female form of last names (except for foreign, i.e. Jewish) always ends in -a. So in this case, ???? or more likely ??????.
  • (cs) in reply to Michael Buschbeck

    Michael Buschbeck:
    Java, I'd say, not JavaScript

    Yeah, could well be, good point.

    Michael Buschbeck:

    Not that Sun's "javac" would be clever enough to recognize that "if (true)" is, in effect, an unconditional branch, too. Hmm, maybe the original author of the quoted code did have a smarter "javac" implementation than Sun's... but then, debug code like this getting into production is just as much a WTF.

    That's deliberately allowed, since "if (constant_expression)" the Java way of doing conditional compilation.  On the other hand, it does seem a bit silly to allow literal true or false, once you've decided to be picky about unreachable code, since the point would be to use static final variables so you can change them more easily.  On the other other hand, adding special cases like that would just make the language more complicated.

    On the subject of smarter Java compilers: the exact reachability rules are defined in the language spec, to preserve the portability of the code - if it works in one implementation, it's supposed to work in any other, at compile time as well as runtime.

  • Olddog (unregistered) in reply to jer
    Anonymous:
    Anonymous:

    I competed in NWERC last sunday... See: http://www.csc.kth.se/contest/nwerc/2006/

    The judge's solutions were posted today... I saw the following line in the code:

    int INF=99999999 

    How would you quantify an infinite value in a finite system? The best you can do is approximate it.

    How would you quantify zero in a finite system? Assuming there's always two halves of any finite value

  • (cs)
    Alex Papadimoulis:

    From the Jan-Feb 1982 of Computer Gaming World (as discovered by Jaliya Jayawardena), here's how we used to patch games before that whole Internet thing was around ...

    [image]

    Full Size: https://thedailywtf.com/images/200611/1982_0102_issue2.gif

    I cannot find much of a wtf here. Maybe it should better say IF RG<1 THEN RG=1. Really, preventing div by zero is so often done in a "lets use the smallest value near to 0 that makes sense" way, that even if it is wrong to do so (often enough its not) is not a wtf anymore.

    But some of the others taught me to not drink while reading this site. Anyone knows how to get coke out of a laptops tft and keyboard?

  • Element (unregistered) in reply to Vasilij
    Anonymous:
    Anonymous:

    reinis:
    ??? is a Russian surname, and ?????? is a male name in Russia.

    So, in Russia it's not a unisex name.

    Nope. Even if it was, the last name would be a giveaway, the female form of last names (except for foreign, i.e. Jewish) always ends in -a. So in this case, ???? or more likely ??????.

     Not necessarily. Zhuk is also an Indian last name. Nikita Zhuk is a very likely name for a female from India =)
     

  • Solarcanine (unregistered) in reply to Element
    Anonymous:
    Anonymous:
    Anonymous:

    reinis:
    ??? is a Russian surname, and ?????? is a male name in Russia.

    So, in Russia it's not a unisex name.

    Nope. Even if it was, the last name would be a giveaway, the female form of last names (except for foreign, i.e. Jewish) always ends in -a. So in this case, ???? or more likely ??????.

     Not necessarily. Zhuk is also an Indian last name. Nikita Zhuk is a very likely name for a female from India =)

     Maybe this page, which conveniently belongs to a Nikita Zhuk involved in comp sci (a likely assumption for anyone related to TDWTF) and includes a picture of said Nikita Zhuk will clear up the specifics of this particular Nikita Zhuk:

    http://www.cs.helsinki.fi/u/nzhuk/

    Of course, someone will have to email Nikita Zhuk to see if we have found the right one.   

  • Nick (unregistered)
    Alex Papadimoulis:

    Nikita Zhuk thought there might be a deeper, more fundamental lack of understanding when she came across this question posted on Experts Exchange ...

    hi all,
    

    IntTemp = Int((255 * Rnd()) + 1)

    I used above ASP.NET code. Problem is in " Rnd() " Rnd() value is changing everytime.

    What is the alternative for Rnd()?
    OR How will stop Rnd() value changes at everytime?

    change the 255 to a 0 and you'll get the same number each time.

    That guy really should get the points for that question.

  • (cs) in reply to Dazed

    Anonymous:
    Anonymous:
    Nikita Zhuk is definitely a "he", not "she"

    Based on what? That you are Nikita Zhuk? I know two Nikitas and they are both female.

    That would make Khrushchev about the ugliest chick in history. 

  • Layne (unregistered) in reply to Quinnum

    And the whole shoe-pounding thing would be a bit ridiculous with a patent leather pump...

  • missing (unregistered) in reply to jer

    Anonymous:
    How would you quantify an infinite value in a finite system? The best you can do is approximate it.

    The same way you write infinity in a finite amount of time, make a special symbol for it. 

  • IronFist (unregistered) in reply to Nick
    Anonymous:
    You

    Screw it, the captcha blocks it all in a few seconds. Anyone know the problem? FF for life.

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

    I competed in NWERC last sunday... See: http://www.csc.kth.se/contest/nwerc/2006/

    The judge's solutions were posted today... I saw the following line in the code:

    int INF=99999999 

    How would you quantify an infinite value in a finite system? The best you can do is approximate it.

    How would you quantify zero in a finite system? Assuming there's always two halves of any finite value



    WTF?!??! That is the biggest wtf so far. Assuming your not being sarcastic
  • (cs) in reply to jer
    Anonymous:
    Anonymous:

    I competed in NWERC last sunday... See: http://www.csc.kth.se/contest/nwerc/2006/

    The judge's solutions were posted today... I saw the following line in the code:

    int INF=99999999 

    How would you quantify an infinite value in a finite system? The best you can do is approximate it.

     I'd approximate it with INT_MAX. Write out the value if I had to. At least that way you can't have a number bigger than infinity.
     

  • Wolven (unregistered) in reply to Nick

    The Rand() question isn't really a WTF: all they wanted to do was seed Rand() before they call it, so that whatever seed will always map to a specific sequence of numbers from Rand(). The WTF is that there are "experts" on expert exchange who couldn't grasp that.

    PS. Sorry if there are like 3 posts saying this exact same thing, but community server seems to be fucked up again, it keeps redirecting me to search whenever I quote-reply to something... Why does anyone bother with this software?
     

  • (cs) in reply to Wolven
    Anonymous:

    The Rand() question isn't really a WTF: all they wanted to do was seed Rand() before they call it, so that whatever seed will always map to a specific sequence of numbers from Rand(). The WTF is that there are "experts" on expert exchange who couldn't grasp that.

    PS. Sorry if there are like 3 posts saying this exact same thing, but community server seems to be fucked up again, it keeps redirecting me to search whenever I quote-reply to something... Why does anyone bother with this software?
     

    Indeed; the WTF for me is that I have to click on the comments link twice to get to the comments; the first time it just sits there for a day and a half; then when I click it again, it goes instantly.

    WTF indeed.
     

  • A chicken passeth by (unregistered)
    [QUOTE] 
    /*Added by Jiang W */
    void ji_suan (int ni_hao)
    {
    int yi_shi = 0;
    // yi_shi = 3 /*erase by Li K */
    yi_shi = 3;
    return;
    }

     [/QUOTE]

    Translation (programmer names omitted):

     void calculate (int hi_there)

    {

        int meaning = 0

        //meaning = 3 /* erased by .. */ 

        meaning = 3

        return

    }

    ...this looks like someone coding in Java for the first time or is trying out something, and is a function that does nothing (after all, it returns nothing despite it being void - god knows why it doesn't generate a compiler error).


     [QUOTE]existingCustomerForm.setError(Boolean.FALSE.booleanValue());[/QUOTE]

    Well, he should be right at home with Visual Studio 2005 at least - you'd be suprised at the number of things you'd need these long lines of declarations for. Heck, you have to import namespace to get to use Booleans and Nulls in VS2005, otherwise you type something like the above. >_>

     
    [QUOTE]

    -------------------------------------------------------------
    -- MBolton 2006-01-13
    -- The //HACK to determine program's parent is very
    -- brittle. Someone should probably fix that. In fact
    -- if you're reading this, it's probably already broken.
    -- Good luck.
    -------------------------------------------------------------

    [QUOTE]

     
    It's official folks. Micheal Bolton is a closet programmer.

    Oh, wait. <_<




     

  • Jasmine (unregistered) in reply to reinis

    Hehe... yeah Elton John confused that whole issue when he made a song called 'Nikita' and then filmed the video with a very hot blonde woman. But doesn't everybody know that Elton John is gay? Clearly the song was about a man. Also, Kruschev was a 'Nikita', and he's definitely a man.

  • EV (unregistered) in reply to EvanED
    EvanED:
    Anonymous:
    Anonymous:

    I competed in NWERC last sunday... See: http://www.csc.kth.se/contest/nwerc/2006/

    The judge's solutions were posted today... I saw the following line in the code:

    int INF=99999999 

    How would you quantify an infinite value in a finite system? The best you can do is approximate it.

     I'd approximate it with INT_MAX. Write out the value if I had to. At least that way you can't have a number bigger than infinity.
     

    INT_MAX may not always be the best value. I have to say I don't really concider this as a WTF, even though I made the first post here.

    Let's say you have to calculate the minimum path from one point to another. You could just do:

    pathlen = current_path + some_other_path;

    if(pathlen &lt; oldpathlen)

       oldpathlen = pathlen;
     

    This way you don't have to check for overflows and still just abuse infinity as being a valid value which will be forgotten because adding something to it will never make it lower than any value in the matrix.

  • Benjamin (unregistered) in reply to PlasmaHH
    PlasmaHH:
    Alex Papadimoulis:

    From the Jan-Feb 1982 of Computer Gaming World (as discovered by Jaliya Jayawardena), here's how we used to patch games before that whole Internet thing was around ...

    [image]

    Full Size: https://thedailywtf.com/images/200611/1982_0102_issue2.gif

    I cannot find much of a wtf here. Maybe it should better say IF RG<1 THEN RG=1. Really, preventing div by zero is so often done in a "lets use the smallest value near to 0 that makes sense" way, that even if it is wrong to do so (often enough its not) is not a wtf anymore.

    But some of the others taught me to not drink while reading this site. Anyone knows how to get coke out of a laptops tft and keyboard?

     

    It is not a wtf. As you may read just under the headline this whole post is about "fun-but-not-necessarily-bad code". It is not bad code, but I still thing it belongs there, because it is funny.

  • (cs) in reply to Jasmine
    Anonymous:
    Hehe... yeah Elton John confused that whole issue when he made a song called 'Nikita' and then filmed the video with a very hot blonde woman. But doesn't everybody know that Elton John is gay? Clearly the song was about a man. Also, Kruschev was a 'Nikita', and he's definitely a man.
    Um, the song is actually about Nikita Kruschev
  • (cs)

    Oh hells yea, that rnd() issue was on side bar once, and it actually stirred up discussion. Unbelievable

    http://thedailywtf.com/forums/thread/98836.aspx 

  • (cs)
    Alex Papadimoulis:

    From A, I guess this just gives a whole new meaning to "Infinity Plus One" ...

    #define INFINITE	10000
    I submitted this. The guy who wrote it spent a long time fiddling with the values of INFINITE before settling on 10000.
    The real wtf for me was the fact that LARGEST_INT was defined in the compiler we were using. 
  • (cs) in reply to abx
    abx:

    Oh hells yea, that rnd() issue was on side bar once, and it actually stirred up discussion. Unbelievable

    http://thedailywtf.com/forums/thread/98836.aspx 

    Hoorah for MS Freecell, the game that actually allows you to set your seed!

  • qbolec (unregistered)

    void ChuckNorris(){
       for(int i=INFINITE; i!=0 ; i+=ZERO){

          if( 0==ZERO) break;
       }
    }

  • (cs)
    Alex Papadimoulis:

    Oscar found this during a recent, and apparently much needed, clean up of the codebase for an application. Good for when the number line reverses itself I suppose?

    if (Math.max(1, 2) == 2) return;

     

    You never know, after spending 3 million years in suspended animation, they might go thru a time hole and end up on an Earth where time goes reverse. Enterprisey future proofness !

  • (cs)

    I'm currently writing an app that, put simply, simulates an electrical diagram.  I have almost the exact same "#define INFINITE 10000" line, except I defined it as 1M.  Put simply, the number represents a resistance and is dropped into a matrix to calculate the voltage at a node.  With a high enough resistance, no electricity goes through the node, due to the other nodes having a resistance of around 10 ohms.  1,000,000 is a high enough number to effectively take the node out of the calculations, but not high enough (>= ~ 1*10^9) to screw up the floating point math so much that the rest of the numbers get thrown off (1000000000000000000+123.456789 = 1000000000000000100).

    If I actually were to use the language's built in "INFINITY", I would get errors all over the place when I do "Infinity/Infinity" math (I want 1, but get an error).  Also, I actually need the extra numbers to be in the matrix, ie I need the number 1,000,015 to have the 15 in it, which Infinity would just drop.

  • (cs)

    That is by far my favorite one. 

    Brandon strapped on his seatbelt and braced himself. He was prepared for return ...

      ...

    /* Prepare for return. */
    return;
    }
     
  • (cs) in reply to A chicken passeth by
    Anonymous:
     
    /*Added by Jiang W */
    void ji_suan (int ni_hao)
    {
    int yi_shi = 0;
    // yi_shi = 3 /*erase by Li K */
    yi_shi = 3;
    return;
    }

     

    Translation (programmer names omitted):

     void calculate (int hi_there)

    {

        int meaning = 0

        //meaning = 3 /* erased by .. */ 

        meaning = 3

        return

    }

    ...this looks like someone coding in Java for the first time or is trying out something, and is a function that does nothing (after all, it returns nothing despite it being void - god knows why it doesn't generate a compiler error).

    Both Java and C/C++ allow return in a void function, even when it's pointless like it is here. It just has to be an empty return. (Reasons for doing it are about the same as using break in a loop.) Though, in the case, the return isn't necessary since void functions also allow falling off...

    Anonymous:


     

    existingCustomerForm.setError(Boolean.FALSE.booleanValue());

    Well, he should be right at home with Visual Studio 2005 at least - you'd be suprised at the number of things you'd need these long lines of declarations for. Heck, you have to import namespace to get to use Booleans and Nulls in VS2005, otherwise you type something like the above. >_>

    Except afaik you can configure the compiler to automatically import System and whatever else you need (Microsoft.VisualBasic for VB.NET, for example). It's a good idea to do it in the file though - you generally can only put so much on a commandline.

  • (cs)

    F(*&($&#@#^$! forum software

     

    I love the Rnd() WTF... they do say any monkey can write ASP... I guess that Monkey doesn't know that though. 

    That's when your buddy says RTFM and you write a post to a forum asking what it means... and some one else says STFW and you ask your buddy what it means.

     

    Sigh... why does this site always look so familiar?
     

  • gl (unregistered)
    Alex Papadimoulis:

    (which simply processes a list of names and converts them to proper case)

     
    Now this is a real wtf.  

    Does anyone think that they can come up with an algorithm that will convert names to 'proper' case?  My name has a capital letter part-way through, but there are some branches of the family that spell it with a lower-case letter (the split happened somewhere in the early 1600's).  There are many other cases, especialy when people have moved to another country and have converted to the 'proper' spelling for that country, but others have maintained the original spellings (think about names that start with 'van der' or Vander'.
     

     

     

Leave a comment on “Coded Smorgasbord: Prepare For Return”

Log In or post as a guest

Replying to comment #:

« Return to Article