• eeman (unregistered)

    so, i feel like my first comment came of as me being a douche. I merely wanted to say that that was not my intent, i was pointing out the accuracy of how crazy engineering terms can sound. (I mean, "nilpotent", really?)

    So, to make up for any impression of malfeasance I may have caused, I offer this: http://youtube.com/watch?v=gdAKgJDahzw

  • (cs) in reply to Paul
    Paul:
    Did anyone else notice the problem between the code:
    if(Ktemp=	273	){return	0	}
    else if(Ktemp=	274	){return	1	}
    else if(Ktemp=	275	){return	2	}
    else if(Ktemp=	276	){return	3	}
    

    and the comment that it could be replaced by:

    "return Ktemp-270;",

    Returns a completely different value 273-270=3, not zero!

    Yes thank you, that's what I was going to mention, even assuming this didn't have thousands of gramatical problems, the math isn't sound either. Nevermind if you're being detailed the conversion from Kelvan to Celsius is actually Kelvin - 272.15 = Celcius (in normal reading not programming format) so nevermind all the other issues with it, that the calculation is technically off, and it very well may be important enough to worry about the .85 of a degree.

  • (cs) in reply to WhiskeyJack
    WhiskeyJack:
    Outlaw Programmer:
    3) Make sure the Johnson rod is functioning correctly.

    There are little pills that can help you with that.

    CODE_BLUE

  • Nilbert (unregistered)

    The guy probably used Excels autofill-feature (or however it's properly called): If you fill a couple of rows with a simple pattern of numbers (such as numbers increasing by one) Excel is able to continue that pattern automatically. He most likely didn't type the whole shebang into Excel after all.

  • (cs) in reply to Spoe
    Spoe:
    IV:
    Simply returning the input - 273 would not give an out of range error. Obviously that would not be a correct solution. the programmer knew what (s)he was doing.
    1. "input - 273" isn't a correct Kelvin to Celsius conversion. You want to subtract 273.15.

    2. returning "input - 273.15" would, IMO, be correct for a conversion function. A conversion function shouldn't be doing any bounds checking outside of those inherent to the conversion (e.g. you can't have a negative temperature in Kelvin). Bounds checking for the specific test should be separate. As written, this TCS couldn't be used to monitor a freezer since anything below the temperature of water is "out of range" nor could it monitor most electronics (Intel, for example, has published maximum case temperatures for normal operation up into the 70s Celsius).

    actually it's 272.15 not 273.15

  • DWL (unregistered)

    Maybe the original programmer was concerned about somebody changing the definition of Celsius and Kelvin...

  • Mark (unregistered)

    What the fuck?

  • SomeCoder (unregistered)

    Wow, I really hope yet another person tells us that the user probably used the Excel Auto fill function. I can only count about 99,999 people who have said that already and I want it to get up to 100,000!

    </sarcasm> :)

  • Anonymous (unregistered) in reply to SomeCoder

    CONGRATS! YOU'RE THE 100,000ND FORUM USER TO MENTION AUTO-FILL! CLICK HERE TO CLAIM YOUR PRIZE!

  • anon (unregistered) in reply to KingNetSurfer
    KingNetSurfer:
    actually it's 272.15 not 273.15

    Well apparently the rest of the world doesn't agree: http://www.bipm.org/utils/common/pdf/its-90/ITS-90_metrologia.pdf

  • runamok (unregistered)

    well... the function does also force the temperature values to be within a 30 degree range. It doesn't do it elegantly, but it does do it.

    But an excel file as a reference with the exact same code is just awesome.

  • Michael Clark (unregistered)

    Quote: Anton wasn’t quite sure why this was used instead of "return Ktemp-270;",

    He didn't use" Ktemp-270;" because that would have been wrong as well. Maybe -273 would have been closer.

  • (cs) in reply to SomeCoder
    SomeCoder:
    Wow, I really hope yet another person tells us that the user probably used the Excel Auto fill function. I can only count about 99,999 people who have said that already and I want it to get up to 100,000!

    </sarcasm> :)

    Exactly, that's TRWTF: the fact that these few comments are repeated throughout 3 pages (so far)...

    Vollhorst:
    Shoudln't worky anyway since he uses = instead of == for comparisons.
    gabba:
    Lots of issues here besides the = vs. == thing.

    -- the returns aren't followed by a semicolon. Won't compile. -- if the temperature is out of range, it simply printf()s a message (also without semicolon) without returning a value. Won't compile. -- extra } at the end. Won't compile.

    Oh, and "Ktemp int" vs. "int Ktemp". Won't compile.

    fennec:
    The other WTFery aside, you don't need formulas to do that easily in Excel. You can just type in the first number (in B1, for instance), type in the second number (B2), select the two cells, then click-and-drag the little dot in the bottom-right corner there as far as you want and it'll fill in the column with the sequence (273, 274, 275... 303)
    Paul:
    Did anyone else notice the problem between the code:
    if(Ktemp=	273	){return	0	}
    else if(Ktemp=	274	){return	1	}
    else if(Ktemp=	275	){return	2	}
    else if(Ktemp=	276	){return	3	}
    

    and the comment that it could be replaced by:

    "return Ktemp-270;",

    Returns a completely different value 273-270=3, not zero!

    Addendum (2008-02-28 10:38): 4 pages...

  • Your Name (unregistered) in reply to K2C

    Don't forget that databases avoid hard coded values, so they can update the program if they definition of celcius changes ; )

  • Keith (unregistered)

    So the kid programmer knew nothing about Engineering or Lord Kelvin's scale. He asked an Engineer to help him, and the Engineer sent him an Excel file. The Engineer doesn't know C, (but maybe Fortran), so he gives the kid a kind of pseudo-code in the Excel spreadsheet, because he got tired of endless questions from the kid. The kid thinks the Engineer knows-it-all, so doesn't bother translating the pseudo-code.

    Hwo it got past his compiler is anybody's guess.

  • (cs) in reply to Medinoc
    Medinoc:
    OK, here, my own WTF was not reading the comments before posting. Type without reading, and you end up with somebody making a profit joke just before you...
    What's the origin of the profit joke? It's one I missed.
  • Teun (unregistered)

    In Excel, you can easily enumerate cells starting from a value without having to enter a formula. My guess is that the programmer did not want to type manually all those lines and found a better way to dos so.

    But again, I don't think he/she has typed every number by hand.

  • krez (unregistered) in reply to Your Name
    Your Name:
    Don't forget that databases avoid hard coded values, so they can update the program if they definition of celcius changes ; )
    SELECT	CASE	WHEN num = 273 THEN 'if(Ktemp=' + CHAR(9)
    			+ RTRIM(CAST(num AS VARCHAR(8000)))
    			+ CHAR(9) + ') {return ' + CHAR(9)
    			+ RTRIM(CAST((num - 273) AS VARCHAR(8000)))
    			+ CHAR(9) + '}'
    		WHEN num > 303 THEN 'else {printf("Temp out of range")}'
    		ELSE 'else if(Ktemp= ' + CHAR(9)
    			+ RTRIM(CAST(num AS VARCHAR(8000)))
    			+ CHAR(9) + ') {return ' + CHAR(9)
    			+ RTRIM(CAST((num - 273) AS VARCHAR(8000)))
    			+ CHAR(9) + '}'
    	END AS LinesOfCode
    FROM	dbo.tblnums
    WHERE	num BETWEEN 273 AND 304
    
  • Dick Asscock, III (unregistered)

    Ah, Excel...everyone thinks they're an expert from the guy that can copy and paste a special format to the guy that can generate a Final Four betting pool.

    I'm a Highly Paid Insultant working with enterprisey stuff. I've witnessed Excel 'experts' manually alpha sort cells because they can show off their mad Ctrl-C/Ctrl-V skillz, but aren't aware of the nifty AZ button. I'd also watch them manually delete duplicate rows without thinking there's a better way (functions 'n filters, yo).

    I knew a "programmer" that would click the down arrow to move down one row at a time for hundreds of rows, not knowing he could just mouseclick below the drag bar.

    These people are out there folks. And, there's money to be made "teaching" 'em until the next generation replaces them with texters expecting to enter a functions in textspeak.

    Peace out, Dick Asscock, III

  • (cs) in reply to KingNetSurfer
    KingNetSurfer:
    Paul:
    Did anyone else notice the problem between the code:
    if(Ktemp=	273	){return	0	}
    else if(Ktemp=	274	){return	1	}
    else if(Ktemp=	275	){return	2	}
    else if(Ktemp=	276	){return	3	}
    

    and the comment that it could be replaced by:

    "return Ktemp-270;",

    Returns a completely different value 273-270=3, not zero!

    Yes thank you, that's what I was going to mention, even assuming this didn't have thousands of gramatical problems, the math isn't sound either. Nevermind if you're being detailed the conversion from Kelvan to Celsius is actually Kelvin - 272.15 = Celcius (in normal reading not programming format) so nevermind all the other issues with it, that the calculation is technically off, and it very well may be important enough to worry about the .85 of a degree.

    272.15 won't work because K2C returns int and has int argument.

  • (cs) in reply to Shinobu
    Shinobu:
    Chris E:
    Nope, missiles still got launched. World saving attempt FAILED.
    You fail at programming. The value of an assignment is the assigned value, in this case 0.

    I seem to remember it's possible to override the = operator in some languages to return something else, such as whether the assignment was successful or not. In which case (code = FALSE) would resolve to true in most cases.

  • (cs)

    int K2C(int Ktemp) { if (Ktemp >= 0)
    return (Ktemp - 273); else { printf("K2C (%d): Out of range\n", Ktemp); return 0; } }

    (if floating point is available:) float K2C(float Ktemp) { if (Ktemp >= 0f) return (Ktemp - 273.15f; else { printf("K2C (%f): Out of range\n", Ktemp); return 0f; } }

  • alan (unregistered)

    I would say that the use of an assignment operator "=" in the if statement as opposed to the use of the proper equality operator "==" is a much larger problem.

  • ClaudeSuck.de (unregistered) in reply to Ken B
    Ken B:
    K2C:
    fist.. and why didn't he just use a database? everyone knows databases are more efficient then excel...
    Of course...
        select C from KtoC where K = %1
    Just remember to wrap it in a COM object and give it an "enterprise" interface.

    You got the point! Why not replace one shit by another? In the end it's a new design and a new development. So, it MUST be better. Some man-months more. If computers were perfect, at least support personnel wouldn't be necessary anymore. Why should we not create unnecessary code that needs unnecessary maintenance just to give us work, and hence food?

  • (cs) in reply to SysKoll
    SysKoll:
    The use of a spreadsheet is a sure sign of a sick mind.

    The "programmer" obviously used the spreadsheet to auto-generate a bunch of lines, probably using some clever formula. This means that the idiot was clever enough to know Excel macros, but too dumb to understand the concept of a temperature difference.

    The guy should be banned from touching a compiler.

    You think way too complicated. He typed in 2 rows, dragged down the selection, and there you have 30 numbers...

  • jon (unregistered)

    umm....

    int K2C(Ktemp int) { return int-273; }

  • ClaudeSuck.de (unregistered) in reply to DWL
    DWL:
    Maybe the original programmer was concerned about somebody changing the definition of Celsius and Kelvin...

    ... one-by-one ...

  • K2C3P0 (unregistered)

    I'm not sure if the real WTF is that the programmers used a table instead of a single equation, that they used excel, or that they used such an inaccurate conversion factor for K2C... ...or maybe it's just the whole thing existing in a happy state of WTFness.

  • Beeblebrox (unregistered) in reply to rohanprabhu
    rohanprabhu:
    neways.. this is one awesome WTF

    WTF is a "neways" ?

  • Beeblebrox (unregistered) in reply to rohanprabhu
    rohanprabhu:
    neways.. this is one awesome WTF

    WTF is a "neways" ?

  • (cs)

    n e ways

  • (cs) in reply to FredSaw
    FredSaw:
    Medinoc:
    OK, here, my own WTF was not reading the comments before posting. Type without reading, and you end up with somebody making a profit joke just before you...
    What's the origin of the profit joke? It's one I missed.
    Well, you're obviously being sarcastic here, Fred.

    However, and to further the interests of the one true gnomic socialism ("Beware, big boy! You're next! Please take your underpants off and leave them by the door"), here's a link for the more culturally retarded amongst us: http://en.wikipedia.org/wiki/Underpants_Gnomes

    See what you've done?

  • (cs) in reply to me
    me:
    Dembinjo:
    Nobody noticed

    if (Ktemp= 273 )

    what about == ?

    And that's really the ONLY non-C thing you noticed? Either this is written in some other (custom?) language or trwtf is that this site's editor or the poster can't even copy code example correctly...

    Ahem.

    It's perfectly legal C.

    A rather pointless way of defining an assignment, followed by a spurious if statement, but perfectly legal. Most compilers would point this out; but no matter.

    And now, back to the bitch-fest.

  • Harisenbon (unregistered) in reply to zip

    I was really surprised how many people overlooked that little point. There's really no other reason to put it in to excel except for the auto generating capabilities.

  • (cs)

    Its WTFs like this that I really find ammusing. There are your everyday run of the mill WTF which are caused by people who don't know a better way, or are lazy.

    But no this guy goes OUT of his way. What was his thought process? "Hmmm 273K is 0C... 274K is 1C.. Man this is taking too long to write. If only I had a system that automatically added numbers for me... Ohh hey I can use Excel to generate the list, and paste it in here..."

  • robbak (unregistered) in reply to KattMan
    KattMan:
    TopicSlayer:
    *slaps head* Grrrrrrrr.... How is it that such simple constructs elude people?

    And now, so I'm not the "asshole" that just criticizes your ignorance without explanation:

    The = operator returns to the left-hand-side the value on the right-hand-side. This behavior allows such statements as a = b = c to set a equal to b equal to c as would be expected. Therefore, returned to the if statement (the left-hand-side) in the above example would be, without surprise, the value zero. This would, as noted, effectively "save the world."

    It seems that some people think that if(x=y) returns the value of if the assignment was successful or not. I don't know how that idea came about, but it seems to be the logic flaw people are following. i.e. The assignment worked, return True! If the assignment didn't work, it would throw an exception instead of false. Like I said, no idea how that got started.

    BTW, HELP DESK GIRL FOREVER! She even has a tattoo!

    It is fostered by constructs like this:

    if( thingy = thing.getnew() ) { do_stuff(); } else { blow_up(); }

    If thingy fails, it returns 0, otherwise it returns the pointer to the new thingie.

  • The Real WTF (unregistered) in reply to K2C
    K2C:
    why didn't he just use a database? everyone knows databases are more efficient then excel...

    Ridiculous! Everyone knows how corrupt databases get and how unstable they are. Stick to flat text files like a normal programmer!

  • David (unregistered) in reply to DeLos

    But K2C always returns 0! (the conditionals are assignments)

  • Lakom (unregistered) in reply to K2C

    Naaaaah.... Databases are too unstable

    Instead he could use plain good ole files... Or better yet a hybrid CSV and XML file like this:

    "ID";"XML" 1;<kelvin_m273>0</kelvin_m273> 2;<kelvin_m273>0</kelvin_m274> 3;<kelvin_m273>0</kelvin_m275> ...

    :-D

  • Lakom (unregistered) in reply to Lakom

    Crap! Fixed it:

    "ID";"XML" 1;<kelvin_m273>0</kelvin_m273> 2;<kelvin_m274>1</kelvin_m274> 3;<kelvin_m275>2</kelvin_m275> ...

  • nat42 (unregistered)

    I believe there was the Excel spreadsheet used a formula and the engineer missed it!

    1. halfwit "programmer" does not know how to convert from degrees K to C and googles it
    2. Finds out the conversion function is already available in Excel and he does not want to reinvent the wheel (a tip he just read about in teach yourself C++ in 24hours)
    3. Our programmer then enters the excel formula he found on the MS site at say cell k5 and proceeds to manually increment the input value and copy the results to the cells of column B - copy/pasting can be fast when you build up a rhythm
    4. After the TCS project is complete the dev, who was paid by the KLoC moves on to a lucrative consulting business, though he no longer preforms WTFs using Excel (he now specialises entirely in wooden tables)
  • nat42 (unregistered) in reply to nat42
    nat42:
    I believe there was the Excel spreadsheet used a formula and the engineer missed it!
    1. halfwit "programmer" does not know how to convert from degrees K to C and googles it
    2. Finds out the conversion function is already available in Excel and he does not want to reinvent the wheel (a tip he just read about in teach yourself C++ in 24hours)
    3. Our programmer then enters the excel formula he found on the MS site at say cell k5 and proceeds to manually increment the input value and copy the results to the cells of column B - copy/pasting can be fast when you build up a rhythm
    4. After the TCS project is complete the dev, who was paid by the KLoC moves on to a lucrative consulting business, though he no longer preforms WTFs using Excel (he now specialises entirely in wooden tables)
    ...oh and 5. He marries Paula-bean and they live happily even after at least until the world end after a missile either goes off or it does (who can tell whats right in this crazy world anyway)
  • Jan (unregistered)

    The real WTF is the author not knowing you can just select two numbers in Excel and drag a corner to make continue a series started by said numbers without having to type a formula.

  • neverending coward (unregistered)

    Just because the cells were not formulas does not mean everything was typed in by hand. Ever used Ctrl-D (copy-down) in excel, or dragged down from the corner? It copies the lines on top down... including figuring out a sequence of numbers once you have one or two in there.

    Not that this makes the WTF any better. ;) Still, just because it's not a formula doesn't mean 'all entered by hand'. (Also, this is a really great tool if you don't want to enter a long series of items by hand)

  • ajk (unregistered) in reply to Andrew
    Andrew:
    Rant: *Anders Celcius named his scale Centigrade. So, that's its name!

    Actually he didn't name it Centigrade - that is the English translation, he called it Celsius as it is still called in Swedish.

  • (cs) in reply to zip
    zip:
    fennec:
    The other WTFery aside, you don't need formulas to do that easily in Excel. You can just type in the first number (in B1, for instance), type in the second number (B2), select the two cells, then click-and-drag the little dot in the bottom-right corner there as far as you want and it'll fill in the column with the sequence (273, 274, 275... 303)

    Thanks for mentioning that. It's not rocket science.

    Well, neither is brain surgery, but some people also don't know much about that. ;)

  • Cpt (unregistered) in reply to DeLos
    DeLos:
    but then the delta is the difference in Celsius! surely you need a K2C function to handle that! //see comment.xls
    Everybody knows that the calculating capabilities in a language as C are limited to subtraction, multiplication and division only (that is the basic reason for a language enhancement as C++, which as the name suggests now contains the addition enhancement). Therefore you need a conversion to allow for addition-like calculations.
  • Loren Pechtel (unregistered)

    I will agree that the Excel stuff was probably done with Excel's autoincrement capability rather than manually typed. I've done a lot of it when working with a very broken system.

    I have also done many tables whose behavior is functionally the same as the stuff in this article--it actually made sense to do it that way as it was so messed up there was no other way to perform fraction -> decimal or decimal -> fraction conversions!

    Finally, with version 2.2 they added external program calls to do these tasks--but there was no way to handle rounding with the decimal -> fraction case so you still had to do it with a huge table.

  • immibis (unregistered) in reply to DeLos
    DeLos:
    but then the delta is the difference in Celsius! surely you need a K2C function to handle that! //see comment.xls
    That would be C2K. Or maybe C2K2C2K. Or maybe ReallyLongFunctionNameButWhatTheFunctionDoesIsItConvertsFromCelsiusOpenBracketDegreeSignTheLetterCCloseBracketToKelvinOpenBracketDegreeSignTheLetterKCloseBracket.

    Contents of comment.xls:

    1,2,3,4,5,3,6,7,8   | but    | then    | the       | delta | is     | difference | in | Celsius!
    1,2,3,4,5,6,7,8,9   | surely | you     | need      | a     | K2C    | function   | to | handle   | that!
    1,2N,3              | //see  | comment | .xls
    1,2,3,4,5           | this   | line    | does      | not   | exist
    1,2,3,4,5           | TODO:  | avoid   | splitting | up    | words
    1N,2,3,4,5,6,7,8N,9 | //     | Delete  | this      | line  | before | posting    | to | thedaily | wtf.com
    
  • immibis (unregistered) in reply to Lakom
    Lakom:
    Crap! Fixed it:

    "ID";"XML" 1;<kelvin_m273>0</kelvin_m273> 2;<kelvin_m274>1</kelvin_m274> 3;<kelvin_m275>2</kelvin_m275> ...

    Fixed it again for you

    <nodConverterList>
     <nodConverter attFrom="celsius" attTo="kelvin" attFromSymbol="C" attToSymbol="K">
      <!-- converts from 0 Celsius to 273 Kelvin -->
      <nodConvert attFromValue="0" attToValue="273" />
      <!-- converts from 1 Celsius to 274 Kelvin -->
      <nodConvert attFromValue="1" attToValue="274" />
      <!-- converts from 2 Celsius to 275 Kelvin -->
      <nodConvert attFromValue="2" attToValue="275" />
    
      <!-- SNIP -->
    
     </nodConverter>
    </nodConverterList>
    

Leave a comment on “K2C”

Log In or post as a guest

Replying to comment #:

« Return to Article