| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |
|
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.
|
Re: The Int Divide
2009-06-10 09:08
•
by
RandomPersona
(unregistered)
|
|
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. |
|
I can't say I really believe this.
|
|
Using SQL to divide two integers is like using an atomic bomb to swat a fly.
|
|
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.
|
|
Concatenating SQL for a statement that is unnecessary in the first place?
|
|
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? |
|
I notice this gem was born on 08/29/08.
So is that YMD or DMY? |
Well, this is really too stupid to be made up. I believe that the (ugly) truth IS out there... |
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? |
|
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!
|
|
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? |
|
It's so cute that he checks the row count of a SQL statement that is not selecting from a table.
|
Bwa ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha ha (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. |
|
...what about the handy integer division operator "\" ?
No no no...on second thought that would've been far too easy. |
Re: The Int Divide
2009-06-10 09:21
•
by
Steve the Cynic
(unregistered)
|
ceil(7) is not floor(7)+1. I reckon this is so that they can have 2/3 => 7 and related sins... |
Re: The Int Divide
2009-06-10 09:23
•
by
Steve the Cynic
(unregistered)
|
|
I suck. Ignore me, didn't read the SQL. Bah.
|
The twenty-ninth month of 2008 is May 2010, whereas the twenty-ninth month of 2008 is May 2010. From this, the answer should be obvious. |
Re: The Int Divide
2009-06-10 09:27
•
by
Yeah Baby
(unregistered)
|
Protip: Near the beginning of every program, include a test IntDivide(2,1) to make sure the database is up. If not, bail out now before you waste time initializing all those variables and plowing halfway through the logic. Optimized! |
|
Can someone expose this as a web service, please? I'm in desperate need of division but cannot set up an SQL server!
|
|
Now I know why they told me that divisions were expensive.
|
Re: The Int Divide
2009-06-10 09:30
•
by
Moredate Madness
(unregistered)
|
This code is from the future!!! Arrrgggghhhhhhhh!!!! (There be terminators about...) |
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. |
How about neither, unless on your planet there are 29 months... How about the standard Month - Day - Year? |
Re: The Int Divide
2009-06-10 09:38
•
by
Moredate Madness
(unregistered)
|
Whoosh! 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. |
|
Is your very first day different from your first day?
|
|
What a shame they had to write another version for Longs not, er, long, afterwards. .NET just isn't good enough!
|
|
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 |
Unless it's perl... Or Microsoft. |
Yes. I was afraid you were going to shoot down my abuse of a jaded meme: '------------------------------------------------------------------ |
Just a minute, I'm trying to figure out how to put the wooden table in for, ya know, enterprisey-ness. |
Re: The Int Divide
2009-06-10 09:53
•
by
Whoevar
(unregistered)
|
... there are lots to choose from? |
Please send teh codez. |
Re: The Int Divide
2009-06-10 09:56
•
by
Brompot
(unregistered)
|
Except that the atomic bomb efficiently swats the fly, with some side effects. |
|
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? |
Really? Can I see your card? I don't believe you. |
|
at least a machine was asked to do the division... he could have asked the user with a captcha...
Prove that you're not a robot. Divide the numbers you see in the image. |
I'll get back to you on that one. Database is down at the moment. |
Re: The Int Divide
2009-06-10 10:21
•
by
girly programmer
(unregistered)
|
and the 29th month is...? |
Re: The Int Divide
2009-06-10 10:24
•
by
My name is missing too
(unregistered)
|
|
But nuking it from orbit is the only way to be sure.
|
|
|
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. |
...WTFuary! |
|
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? :) |
|
The design document probably specified that all computations be performed on the database.
|
|
And the correct answer to this will prove the user IS a robot, right?
|
I mean, "953281 / 713 ______________" :) |
Re: The Int Divide
2009-06-10 10:41
•
by
Brady Kelly
(unregistered)
|
This forum really needs a (hand slapping forehead) "Duh!" icon. Welcome, genius. |
| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |