- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
why didn't he just use a database? everyone knows databases are more efficient then excel...
Admin
The real WTF is definitely forgetting about the panendermic semiboloid. That's inconceivable. INCONVEIVABLE!
Admin
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.
BTW, why have no comment on the comic been photographed on a wooden table? I keep scrolling through, but apparently no one knows the proper way of creating an image for a website.
Captcha: dignissim.
Admin
You keep using that word. I do not think it means what you think it means.
Admin
Shoudln't worky anyway since he uses = instead of == for comparisons.
Admin
trwtf is that they didn't just replace the entire system with one or two lunar wainshafts and a differential girdle spring.
Admin
Nobody noticed
if (Ktemp= 273 )
what about == ?
Admin
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.
Admin
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.
Admin
Admin
I guess all the temperature differentials were exactly zero. Not very useful I imagine.
Admin
but then the delta is the difference in Celsius! surely you need a K2C function to handle that! //see comment.xls
Admin
Clearly, he should have rerouted the tachyon beam through the forward deflector, remodulated the forward phaser bank, and ordered number one to take a number two.
Admin
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.
Admin
Looking at that last else, it shouldn't even compile. Not all code paths return a value...
Besides, there's a braces mismatch in the last line. The real WTF is someone who put non-compiling code into the source...
Admin
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)
Admin
Admin
Its also missing semi-colons. Maybe its a 'C' like language, or probably an obfuscation issue.
Admin
Thanks for mentioning that. It's not rocket science.
Admin
The Real WTF is that he never found out what was actually causing the problem. A bit of a tease, this one.
Admin
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. In cases it's not a number, it just repeats that data through the cell. that's why maybe he typed the numeral values in different cells and just dragged the whole thing down.
neways.. this is one awesome WTF
@DeLos: Since the Celsius-Kelvin are difference scales and not factor scales, the delta is same in both Celsius and Kelvin.
Admin
maybe, just maybe, i would like to think that the excel table was meant to be an interpolation table to account for non-linear sensors.
however, as interpolation like that is extremely non-trivial, I wouldn't doubt that the original programmer got hung up on it and just threw something together.
Admin
There are plenty of problems besides not returning a value. GCC only gives a warning, and even then, only if you ask for warnings.
Admin
It's not even spelled the way he thinks it's spelled--at least not when in ALL CAPS.
Admin
Did anyone else notice the problem between the code:
and the comment that it could be replaced by:
"return Ktemp-270;",
Returns a completely different value 273-270=3, not zero!
Admin
Admin
how would the code work if the code should be Ktemp==273
while if he uses Ktemp=273, it'll just assign the rhs value to the lhs and the program won't work.
Admin
/* world's last mistake in C */ if(code = CODE_RED) { launch_missles(); }
Admin
Admin
The sudden influx of technobabble concentration causes fluctuation of the distortion field, and we may have to remodulate the confinement of the problematic plasma flow to prevent its further deterioration.
Admin
They might not have hand typed the xls file. In excel there's a way to fill a row down and have it auto increment each row.
Another possibility I've done/seen is to make a formula, implement it, once you have the correct data, copy the entire book, then paste special it as "just values" this way no one can muck up your data.
Just because the final output doesn't have the formulas doesn't mean he didn't use some of the easier tools in Excel, otherwise he likely would have created these files in C++/other language.
Admin
Well, no shit, sherlock. It's a standalone function, not a complete program. There obviously won't be any #includes.
Admin
Admin
I can't believe I forgot to put this in my last post. The code could be made so much more efficient via use of the switch. Maybe that is the point in the article we have all been missing.
captcha: quibus
Admin
The real wtf is obviously using
C = k - 273
Should be
C= k - 273.15
Admin
Yeah, to quote another post here "No shit, sherlock!" Did you not see the other posts that said it might be an in-house C like language, or a mistype in copying the code.
Admin
Admin
Nope, missiles still got launched. World saving attempt FAILED.
Admin
(but you are lucky that he is only launching 'missles', whatever they are, not 'missiles')
Admin
That will just put code to 0 and fire them anyway.
Admin
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:
Admin
Does that even compile? I thought the return statements had to have a semicolon...
Admin
World's safe...for now. ;-)
Admin
Functions are not required to return a value in C (or, for that matter, C++). A C programmer would know that.
Of course the value returned by such a function is undefined (usually whatever's lying around in the appropriate register):
Admin
...until some smartass maintainer "fixes" the "bug" in the 'if' statement, and checks in without testing.
Admin
Regardless of the code always returning 0, the suggestion in the article that the entire method could be replaced by "return Ktemp-270;" is incorrect. It should be: "return Ktemp-273;" and that is what the original poster is pointing out.
Admin
To quote Pratchett, "Of course someone would be that stupid. Some humans would do anything to see if it was possible to do it. If you put a large switch in some cave somewhere with a sign on it saying "End-of-the-World Switch. PLEASE DO NOT TOUCH," the paint wouldn't even have time to dry."
Admin
[obligatory]
Admin
I call reasonable doubt on the "all typed by hand" of the Excel file. The programmer could very well have used the type-and-drag feature of Excel (type number, select cell, drag down, ????, profit!)...
Admin
if(code = 0) { launch_missles(); }
if(0) { launch_missles(); }
; //Notice how nothing happens