- 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
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
Admin
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.
Admin
CODE_BLUE
Admin
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.
Admin
actually it's 272.15 not 273.15
Admin
Maybe the original programmer was concerned about somebody changing the definition of Celsius and Kelvin...
Admin
What the fuck?
Admin
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> :)
Admin
CONGRATS! YOU'RE THE 100,000ND FORUM USER TO MENTION AUTO-FILL! CLICK HERE TO CLAIM YOUR PRIZE!
Admin
Well apparently the rest of the world doesn't agree: http://www.bipm.org/utils/common/pdf/its-90/ITS-90_metrologia.pdf
Admin
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.
Admin
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.
Admin
Addendum (2008-02-28 10:38): 4 pages...
Admin
Don't forget that databases avoid hard coded values, so they can update the program if they definition of celcius changes ; )
Admin
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.
Admin
Admin
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.
Admin
Admin
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
Admin
Admin
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.
Admin
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; } }
Admin
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.
Admin
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?
Admin
Admin
umm....
int K2C(Ktemp int) { return int-273; }
Admin
... one-by-one ...
Admin
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.
Admin
WTF is a "neways" ?
Admin
WTF is a "neways" ?
Admin
n e ways
Admin
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?
Admin
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.
Admin
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.
Admin
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..."
Admin
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.
Admin
Ridiculous! Everyone knows how corrupt databases get and how unstable they are. Stick to flat text files like a normal programmer!
Admin
But K2C always returns 0! (the conditionals are assignments)
Admin
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
Admin
Crap! Fixed it:
"ID";"XML" 1;<kelvin_m273>0</kelvin_m273> 2;<kelvin_m274>1</kelvin_m274> 3;<kelvin_m275>2</kelvin_m275> ...
Admin
I believe there was the Excel spreadsheet used a formula and the engineer missed it!
Admin
Admin
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.
Admin
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)
Admin
Actually he didn't name it Centigrade - that is the English translation, he called it Celsius as it is still called in Swedish.
Admin
Well, neither is brain surgery, but some people also don't know much about that. ;)
Admin
Admin
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.
Admin
Contents of comment.xls:
Admin
Fixed it again for you