- 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
In other news, the original 0 Celsius was, in fact, the boiling-point of water, not the tri-state point.
I imagine that this is quite important when you deal with locales and epochs and stuff.
Admin
I can't believe I just said that.
Admin
You need to do this if you're going to lift copy verbatim, otherwise it looks like your implying that you wrote it.
Admin
They may also want to get a decent C compiler that would flag the missing return statement as an error. Then fire whoever wrote that drivel.
Admin
Hmm, I don't know what language or processor you're using, but any platform I've ever worked on, doing an IF is way slower than doing a subtraction.
At the machine level, doing "if x==y" normally involves: load x into a register, subtract y, compare result to zero, if result is zero (or is not zero, as the case may be) jump somewhere. That is, every compare involves an internal subtraction, PLUS doing the compare and the go-to. Even machine languages that support direct memory-to-memory compares take more cycles to do it than they do for a subtraction.
And in the if/then/else method, you wouldn't do just one compare unless you got a match on the very first try. You might have to do dozens of compares.
If/then/else could be faster than a calculation if the calculation is complex. But it's not going to beat a simple subtraction.
Admin
Admin
Zero is always returned from the function K2C(), if this C is a standard C based compiler.
To explain, here is the topmost line:
The if statement always evaluates to true because using the "=" assignment ( versus the "==" equality check ) will always be the value 273, or, true.Thus, the function always returns 0.
In fact, a good optimizing compiler will remove most of the remaining code in the function, and this becomes a very small function at the binary level.
Admin
You're totally right - I think I was having a brain fart when I wrote that. I've had a hard week writing flight control software for the Boeing 777, mwuhahahahah (only kidding!) The multiple if..elses would not only take far longer, they'd also be unpredictable for a real-time system. I had in mind more complex arithmetic operations.
Admin
This is what happens when schools shrug their responsibility to teach students to question things and think for themselves.
Admin
i really don't know what to say . the difference is the same no matter what the units are !!. urgh... WTF indeed
Admin
Beyond the fact that all of this is unnecessary code, I'm more concerned with the fact that if any of those temperatures are outside the range [0C,30C], the K2C function returns garbage... so there is a bug in the software...
Admin
Did nobody notice that the code used = instead of ==?
If this was a C program it would have always returned zero!
D
Admin
This is incredible! I hope this "programmer" is doing better with electronics !
Admin
Well this whole story is made up from scratch, not a grain of truth in it.
For instance "inverse reactive current in a unilateral phase detractor." is taken directly from a spoof vid on youtube.
http://youtube.com/watch?v=i3RqDp7i308
and so is this line: "temperature control board’s panendermic semiboloid to the "up" end of his grammeter."
Admin
This code shouldn't work, it has = instead of == in comparison. The line
Would firsth assign 273 to Ktemp variable, and then promptly return 0.
DeLos: It doesn't matte if the difference is in Celsius or Kevin. Diff in kevins: k1-k2, is the same as diff in celcius: c1-c2 = k1-273 - (k2-273) = k1 -273 - k2 + 273 = k1 -k2
Admin
You dont neled to type it in by hand
Enter say,
Testing 1 string Testing 2 string Testing 3 string
In 3 cells in a column, select them all and click and drag the little black box on the bottom right hand corner. It will copy that with the numbers changing into each one.
Admin
The excel might not have been typed by hand - they could have used 'complete down' to fill-in the columns based on 2 rows of examples, and that would have left values rather than formulae in the spreadsheet