• (cs) in reply to Chris E
    Chris E:
    (but you are lucky that he is only launching 'missles', whatever they are, not 'missiles')

    I wonder if missles are related to breastles?

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

  • Anders Munch (unregistered)

    My guess is that the developer planned for calibration of the temperature sensors, but never got around to it. The real WTF is not observing YAGNI.

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

  • TopicSlayer (unregistered) in reply to Carra
    Carra:
    Christian:
    Whoops:
    This reminds me of a very funny joke:

    /* world's last mistake in C */ if(code = CODE_RED) { launch_missles(); }

    const int CODE_RED = 0; /* saved the world */

    That will just put code to 0 and fire them anyway.

    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."

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

    There are little pills that can help you with that.

  • Mike Dimmick (unregistered) in reply to Chris E
    Chris E:
    Nope, missiles still got launched. World saving attempt FAILED.
    No, that's not how the assignment bug works. The result of the expression code = CODE_RED is whatever value was assigned to code, i.e. the value of CODE_RED. The if statement treats 0 as false and anything non-zero as true, so setting CODE_RED to 0 would prevent the missiles from being launched.

    Unfortunately, it would prevent them from ever being launched, as it would always evaluate false regardless of the value of code.

  • (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.

    Guess I'm the only Seinfeld fan here...

  • Andrew (unregistered) in reply to t
    t:
    It's worth pointing out, for those who didn't realize it, that finding the difference between two temperatures in Celsius yields the exact same result as taking the difference of the temperatures in Kelvin.

    So in those precious few occurrences, the function calls had no effect on the value of the expression.

    Yes, the Kelvin scale is a linear shift from the Centigrade* one. So, there is no useful reason to convert. However, I'm pretty sure that the shift is +273.15K = 0C.

    Why aren't their thermometers more accurate? The K2C() function uses integers, not floating point. That's a bigger WTF!?!

    Rant: *Anders Celcius named his scale Centigrade. So, that's its name!

    The proposed Metric "Grade" (100 G = 90 Degrees) angle is not in use. So, the "Centigrade" (1/100th of a Grade) does not exist!

    The real Metric angle measure is (and should be) Radians!

  • (cs) in reply to shadowman
    shadowman:
    jspenguin:

    $ gcc -Wall k2c.c -c -o k2c.o k2c.c: In function ‘K2C’: k2c.c:35: warning: implicit declaration of function ‘printf’ k2c.c:35: warning: incompatible implicit declaration of built-in function ‘printf’ k2c.c:36: warning: control reaches end of non-void function

    There are plenty of problems besides not returning a value. GCC only gives a warning, and even then, only if you ask for warnings.

    Well, no shit, sherlock. It's a standalone function, not a complete program. There obviously won't be any #includes.

    I was speaking of the "control reaches end of non-void function".

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

    There are little pills that can help you with that.

    Guess I'm the only Seinfeld fan here...

    Oh you need a new Johnson Rod. Oh well better install one of those...

    :)

  • Izzy (unregistered)

    Obviously the real WTF is failing to issue an "Out of Range" message if the temperature is under 273K. The excessive line-by-line coding for each degree is merely from being paid by the line.

    It would also work much better if the framistat was degreased, calibrated and photographed on a wooden table.

  • Pat (unregistered) in reply to Outlaw Programmer
    Outlaw Programmer:
    The real WTF is that he realized that not only is that function a complete mess, but it's totally unnecessary and he should have removed it. Every codebase has crappy code, but if you just leave it lying around without doing anything about it you're only adding to the problem.

    I wasn't aware hardware guys had write access to the code.

  • Izzy (unregistered) in reply to Izzy

    That makes no sense. Of course it gives a warning on low temps. [I need more coffee.]

  • (cs) in reply to rohanprabhu
    rohanprabhu:
    @DeLos: Since the Celsius-Kelvin are difference scales and not factor scales, the delta is same in both Celsius and Kelvin.

    Yup. I find jokes funnier after you explain them too.

  • (cs) in reply to Zylon
    Zylon:
    The Real WTF is that he never found out what was actually causing the problem. A bit of a tease, this one.
    The Article:
    This whole time, it was his fault: he neglected to connect the temperature control board’s panendermic semiboloid to the "up" end of his grammeter. Obviously, this caused very high levels of sinusoidal depleneration and, hence, strange readings. And to think… he was about to call the programmer’s work a WTF!

    There is your answer.

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

    There are little pills that can help you with that.

    Guess I'm the only Seinfeld fan here...

    Oh you need a new Johnson Rod. Oh well better install one of those...

    :)

    George Costanza:
    Well, of course they're trying to screw you. What do you think?

    That's what they do. They can make up anything. Nobody knows. "By the way, you need a new Johnson rod in there." "Oh, a Johnson rod. Yeah, well, you better put one of those on."

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

  • Manu (unregistered) in reply to rohanprabhu
    rohanprabhu:
    he probably used excel to type in a number value in a cell and then drag the small dot in the bottom-right of the cell downwards and microsoft fills the cells incrementing the number.

    Oh thank god I was starting to fear that nobody here knew about that functionality :)

    I concur. He must have thought "gee, I don't want to type a lot of consecutive numbers", and Excel is a nice "trick" to help you do that.

    Of course, the REAL WTF is that he knows tricks like that, but doesn't realize that he could (should) make it into a function...

  • (cs) in reply to Spoe
    Spoe:
    1) "input - 273" isn't a correct Kelvin to Celsius conversion. You want to subtract 273.15.
    That works real good for integer data types, which is what these are, in case you didn't notice.
  • Paul (unregistered)

    I would have rewritten the whole application as a web 2.0 application, and included a Fahrenheit converter for American users, using an XML-base configuration file to specify the temperature scale per locale. Of course, it would need a TemperatureScaleFactory to get the correct scale.

    And since F = 9*(K - 273.15)/5 + 32 is too processor intensive, I would just use a combination of the simplification I use when I check the weather when I'm in Europe and a simpler way of getting celsius from Kelvin:

    F = C*2 + 30 = (K - 270)2 + 30 = K2 - 510.

    273K comes out as 36F, 173K (boiling point) would be 164F. Of course, I would need a F2K function to compute the K2F(t1) - K2F(t2) difference in Kelvin. Hold on ... would that work? ... hmm never mind, too close to the deadline, we'll fix it in the next release. There's a workaround anyway, just use a calculator.

  • Kluge Doctor (unregistered) in reply to fennec
    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)
    CAPTCHA: autofill
  • PseudoNoise (unregistered) in reply to Christian
    Christian:
    Whoops:
    This reminds me of a very funny joke:

    /* world's last mistake in C */ if(code = CODE_RED) { launch_missles(); }

    const int CODE_RED = 0; /* saved the world */
    That's all kinds of awesome.
  • (cs) in reply to Outlaw Programmer
    Outlaw Programmer:
    The real WTF is that he realized that not only is that function a complete mess, but it's totally unnecessary and he should have removed it. Every codebase has crappy code, but if you just leave it lying around without doing anything about it you're only adding to the problem. The correct solution is:
    1. Delete that function.
    2. Change the few occurrences so that it just uses difference in Kelvin temps.
    3. Make sure the Johnson rod is functioning correctly.
    Yeah, I get very embarrassed when *my* johnson (ahem) rod malfunctions...
  • Spoe (unregistered) in reply to Simetrical
    Simetrical:
    Spoe:
    1) "input - 273" isn't a correct Kelvin to Celsius conversion. You want to subtract 273.15.
    That works real good for integer data types, which is what these are, in case you didn't notice.

    Of course I did. You can't convert integer Kelvin to integer Celsius. In this case, yes, the effect is fairly benign (due to the straight additive nature of the conversion) and may well be withing the engineering tolerances needs, but can lead to error.

    For example, if you're trying to maintain a temperature above the freezing point of water this conversion will convert a temperature slightly below freezing (273 Kelvin) into freezing (0 Celsius or 273.15 Kelvin). And depending on what other operations might be done on the converted temperatures, this error can snowball.

    Or maybe I just spent too much time in the physics program before switching to CS.

  • miraclemax (unregistered) in reply to mrprogguy

    The real WTF here, obviously, lies in arguing with a Sicilian when life is on the line.

  • (cs) in reply to TopicSlayer
    TopicSlayer:
    Carra:
    Christian:
    Whoops:
    This reminds me of a very funny joke:

    /* world's last mistake in C */ if(code = CODE_RED) { launch_missles(); }

    const int CODE_RED = 0; /* saved the world */

    That will just put code to 0 and fire them anyway.

    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!

  • Matthew (unregistered) in reply to K2C

    Best. WTF. Ever!

    I actually had to cover my mouth to contain the hysterical laughter to avoid making a scene.

  • from the future (unregistered)

    const int CODE_RED = 0; /* saved the world */

    You fool. Missles are things which prevent the collision with the asteroid. World destroyed !

  • eeman (unregistered)

    Clearly, he should have modeled the temperature as a wide sense stationary, mean ergodic stochastic process and run it through a 14th order filter with a nilpotent matrix representation, and taken the square root of the power spectral density.

    oh, wait, those are actually real things. my bad.

    captcha: sino => sin(0)

  • (cs) in reply to from the future
    K2C:
    const int CODE_RED = 0; /* saved the world */

    You fool. Missles are things which prevent the collision with the asteroid. World destroyed !

    ... or errant spy satellites?

  • (cs) in reply to KattMan
    KattMan:
    TopicSlayer:
    Carra:
    Christian:
    Whoops:
    This reminds me of a very funny joke:

    /* world's last mistake in C */ if(code = CODE_RED) { launch_missles(); }

    const int CODE_RED = 0; /* saved the world */

    That will just put code to 0 and fire them anyway.

    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!

    There's sort of an idea that there are two kinds of functions:

    a) Functions which return stuff

    b) Functions which do stuff

    Most operators are in the a) category, but = is in the b) category. And most functions in the b) category return whether the doing stuff worked, not what was done. Although in various situations you can have a function do BOTH, if it's typed like PHP or you can have a return value that specifically means 'failed'.

    But generally.. a function that does something, usually is considered to fail or succeed, and returns like that. = is kind of an anomaly in that respect. No part of "Assign left value to right variable" implies "return the new value of the right variable"

  • Excel Using Coward (unregistered) 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.

    Also has no one heard of Paste Special -> Values before?

  • Nevs (unregistered)

    He didn't type in B1, B2, B3 manually, he grabbed the first value and dragged downwards, letting excel add one on each time for him.....rinse and repeat for D.

    I think he deseves a break for speeding up the development process.........maybe not.

  • Dalceon (unregistered)

    This causes me pain.

  • (cs) in reply to webrunner
    webrunner:
    KattMan:
    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!

    There's sort of an idea that there are two kinds of functions:

    a) Functions which return stuff

    b) Functions which do stuff

    Most operators are in the a) category, but = is in the b) category. And most functions in the b) category return whether the doing stuff worked, not what was done. Although in various situations you can have a function do BOTH, if it's typed like PHP or you can have a return value that specifically means 'failed'.

    But generally.. a function that does something, usually is considered to fail or succeed, and returns like that. = is kind of an anomaly in that respect. No part of "Assign left value to right variable" implies "return the new value of the right variable"

    In C, = is not a function. It's like +, or +=. It has specially handling and therefore should not be expected to follow the "rules" of functions. In C++/C#, and other more modern languages, =, +, +=, etc, are all functions now. However, these languages also have exceptions, and so functions no longer return "success" or "fail", they instead are implicitely successful unless you recieve an exception. It is also not actually rare to have a function that does something and returns something. You sometimes have functions that do things and return many things (thanks to out parameters/pointers or referances).

  • Jay (unregistered) in reply to Pat
    Pat:
    I wasn't aware hardware guys had write access to the code.

    You know what they say the three scariest things in the world are:

    1. A programmer with a screwdriver.
    2. A hardware guy with a "Teach Yourself Java" book.
    3. A user with an idea.
  • (cs)

    The real WTF is giving users access to source code (even if it's read only). That just leads to problems with "smart" users who think they know what they're talking about.

  • "return Ktemp-270;" ? (unregistered)

    I always thought absolute zero is at -273,15˚C ...

  • Jay (unregistered) 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).

    Uh, yes. I think the problem here is that IV was telling what is sometimes technically referred to as a "joke".

    I suppose you are also complaining that "getting to the other side" is clearly only an intermediate goal and the last speaker has still failed to adequately explain the chicken's underlying motivation.

  • hexapod (unregistered)

    "Someone had apparently typed each Kelvin and degree Celsius value in by hand"

    I suppose it's possible that the person was spreadsheet-y and did a click-drag to fill in the linear steps..

  • mithras (unregistered)

    Isn't TRWTF the assignment-instead-of-equality-operator?

  • (cs)

    This is the best WTF that I've seen in a while. It's a CWTF (Cascading WTF).

    I was kinda expecting to see a "See tempconv.csv" somewhere on that sheet.

  • Kson (unregistered) in reply to DeLos

    Doesn't if (Ktemp = 273) always true?

  • Fant (unregistered) 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.

    I bet they only used Excel's handy auto-increment feature to generate the list of Kelvin and Celsius numbers. If you need to generate a list of numbers from 1..30 quickly, Excel's one of the fastest non-programming ways to do it.

  • duh (unregistered) in reply to DeLos

    You don't have to type all of those lines in by hand to avoid not using a function in excel. You just highlight all of the cells and in the bottom right corner of the highlighted area is a box you can drag down and it will copy the cells down using "AI" in the instances where a number should just be incremented on each subsequent copy.

    For example, type in A1: 1, then in A2: 2, highlight both A1 and A2 then drag the box down.

    Excel was a perfectly good solution for producing that type of code!

  • jbinaz (unregistered)

    It's amazing how many places I've seen Excel as a "data source". I just finished maintaining/fixing a classic ASP app that did just that.

    There was a field "Employees Trained" that was kept in an excel spreadsheet. The app opened up the spreadsheet, read that value, and then put it on the front page informing everyone how many users had been trained.

    Don't change the spreadsheet name or it breaks.

    Heaven forbid someone either put it in an include file (remember, classic ASP) or even better, have and admin page where the user can actually change that value. Or put it in the HR system when a user is trained and read from that. But in an excel spreadsheet? Yikes!

  • (cs)

    On my first reading of this, I read tempconv.xls as tempconv.xsl, and got all enterprisey excited. Imagine the letdown to see dumb old Excel and not a stylesheet.

    Oh, and absolute zero is 0 Rankine.

    Addendum (2008-02-27 15:21): BTW: 0 Rankin is the temperature that The Bumble froze.

  • jbinaz (unregistered)

    It's amazing how many places I've seen Excel as a "data source". I just finished maintaining/fixing a classic ASP app that did just that.

    There was a field "Employees Trained" that was kept in an excel spreadsheet. The app opened up the spreadsheet, read that value, and then put it on the front page informing everyone how many users had been trained.

    Don't change the spreadsheet name or it breaks.

    Heaven forbid someone either put it in an include file (remember, classic ASP) or even better, have and admin page where the user can actually change that value. Or put it in the HR system when a user is trained and read from that. But in an excel spreadsheet? Yikes!

  • (cs) in reply to Medinoc
    I bet they only used Excel's handy auto-increment feature to generate the list of Kelvin and Celsius numbers. If you need to generate a list of numbers from 1..30 quickly, Excel's one of the fastest non-programming ways to do it.
    That's almost certainly what happened. It will fill values for a sequence rather than a formula.

Leave a comment on “K2C”

Log In or post as a guest

Replying to comment #:

« Return to Article