- 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
Ouch!
Admin
Seems simple enough. The built-in division function returned all kind of crazy "NaN" stuff sometimes. Only IntDivide can be relied upon to tell you that any number divided by zero is zero.
Admin
Wow. I do not think I have ever seen code that is wrong on so many levels.
In fact, before now, I wouldn't have thought it would be possible to introduce 200ms latency in to a divide operation.
I feel like I'm being trolled, but I can't help but believe someone actually wrote this.
Admin
I can't say I really believe this.
Admin
Just awesome!
Admin
Using SQL to divide two integers is like using an atomic bomb to swat a fly.
Admin
OK, this one counts as an actual WTF. I was expecting the poorly implemented and completely redundant function with unspecified results under certain cases (like dividing by zero) but the SQL caught me by surprise to the point that I said "What?" out loud! Good one.
Admin
Concatenating SQL for a statement that is unnecessary in the first place?
Admin
ROFL. Well at least he set Result to zero when he declared it! Because no one knows what its value would have been if he hadn't.
Is there a SQL Math for Dummies book or something?
Admin
I notice this gem was born on 08/29/08.
So is that YMD or DMY?
Admin
Well, this is really too stupid to be made up. I believe that the (ugly) truth IS out there...
Admin
Same here. Actually I was expecting the implemented function to end up working properly in all cases except where the numerators were actually evenly divisible by the denominators. But making a call to the database to divide two numbers is just...seriously what the hell were they thinking?
Admin
If the database is down, an exception is thrown during some int division, instead of during an actual intended database operation; potentially averting horrendous failure. Solid!
Admin
Why bother with returning the floor in place of this IntDivide if you're just going to add one to it? Why not return the ceiling instead. Granted, I don't know how the SQL result will be returned in this particular implementation, but it seems from the article that it returns the floor. Therefore, if you take the floor plus one, that should equal the ceiling, no?
Or am I thinking of the ceiling of (numerator+.5)/denominator?
Admin
It's so cute that he checks the row count of a SQL statement that is not selecting from a table.
Admin
(deep breath)
ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha
I get one hell of a kick out of people who believe something is "so stupid" that it couldn't possibly happen in real life. Oh my dear $DEITY, the secondary entertainment value is so exquisite . . .
I not only believe this code is in production somewhere, I cannot help but admire the "Who: ????" as well.
Admin
...what about the handy integer division operator "" ? No no no...on second thought that would've been far too easy.
Admin
ceil(7) is not floor(7)+1.
I reckon this is so that they can have 2/3 => 7
and related sins...
Admin
I suck. Ignore me, didn't read the SQL. Bah.
Admin
Admin
Admin
Can someone expose this as a web service, please? I'm in desperate need of division but cannot set up an SQL server!
Admin
Now I know why they told me that divisions were expensive.
Admin
(There be terminators about...)
Admin
http://www.google.com/search?q=[insert math to perform here]
Done. It's even abstracted to handle assorted unit conversions, trigonometry, complex numbers... the list goes on!
Now you just have to write a neural network to learn how to extract the answer from any arbitrarily formatted Google result page (what if they change the logo?) and you're all set. No Quack.
Admin
How about the standard Month - Day - Year?
Admin
Ummm, which "standard" is that?
Year-Month-Day is the International Standard http://en.wikipedia.org/wiki/ISO_8601
And, as is the nature of standards, there is only one right way to do it.
Admin
Is your very first day different from your first day?
Admin
What a shame they had to write another version for Longs not, er, long, afterwards. .NET just isn't good enough!
Admin
He's not alone. I've seen worse. In fact just yesterday I decided to help a forum poster who had switched to SQL Server because Access didn't allow enough column on a data table. He was recursively using a function which downloaded the a database table to flesh out a parse tree and couldn't understand why he was running out of system memory.
These people really do exist
Admin
Unless it's perl... Or Microsoft.
Admin
Admin
Just a minute, I'm trying to figure out how to put the wooden table in for, ya know, enterprisey-ness.
Admin
... there are lots to choose from?
Admin
Please send teh codez.
Admin
Except that the atomic bomb efficiently swats the fly, with some side effects.
Admin
See, is not the language's fault that stupid people like this guy use them.
BTW, is it bad that my debit card PIN is the same as their security lock?
Admin
Really? Can I see your card? I don't believe you.
Admin
at least a machine was asked to do the division... he could have asked the user with a captcha...
Admin
I'll get back to you on that one. Database is down at the moment.
Admin
and the 29th month is...?
Admin
But nuking it from orbit is the only way to be sure.
Admin
Admin
I like the fact that if any of his If clauses should fail for whatever reason, the function will happily return 0.
I can just imagine this being used in a financial application.
Admin
Admin
This is probably just some ingenious way to move some load from the application server to the database server. Ever heard of cloud computing or data grids? :)
Admin
The design document probably specified that all computations be performed on the database.
Admin
And the correct answer to this will prove the user IS a robot, right?
Admin
I mean, "953281 / 713 ______________" :)
Admin
This forum really needs a (hand slapping forehead) "Duh!" icon.
Welcome, genius.