
I wish they'd just pretend the answer is the largest possible number that fits in the data type, and not throw an error. Data types that hold NaN and infinity aren't much help either, since they ruin all further calculations.
It's also irritating when I'm trying to translate some equation into C and it's 1) written the wrong way round so that it doesn't help with finding the answer, like it's in Haskell or something, and 2) has all the multiplication signs missing so I can't read it properly. Basically mathematicians ruin everything.
( ,
Sun 6 Jul 2008, 12:35,
archived)
It's also irritating when I'm trying to translate some equation into C and it's 1) written the wrong way round so that it doesn't help with finding the answer, like it's in Haskell or something, and 2) has all the multiplication signs missing so I can't read it properly. Basically mathematicians ruin everything.

Or will that involve working out what the largest possible number is, then using that instead of 0?
( ,
Sun 6 Jul 2008, 12:38,
archived)

You have to keep saying "Wait! Is that input zero? In that case don't try the calculation, you'll only get upset. Here, I'll do it for you, the answer is such-and-such."
( ,
Sun 6 Jul 2008, 12:41,
archived)

C is a pain in the arse at the best of times but can't you actually redefine the NaN to be the maximum?
I dunno this is getting out of my area...
( ,
Sun 6 Jul 2008, 12:46,
archived)
I dunno this is getting out of my area...

in that you can't rely on being able to do it with different chips, operating systems, libraries or whatever.
I might be wrong, though, maybe in the modern age we should in fact be doing exactly this and all the examples I see that catch divide by zero errors are just being anal.
( ,
Sun 6 Jul 2008, 12:56,
archived)
I might be wrong, though, maybe in the modern age we should in fact be doing exactly this and all the examples I see that catch divide by zero errors are just being anal.

kind of:
int funkydiv (int a, int b) {
if(b == 0) return MAX; else return a/b;
}
so long as you make sure it's distinguished from the built-in int type. also, i don't know what c's like for overloading operators, but it'd be a piece of piss to overload the division operator in c++
( ,
Sun 6 Jul 2008, 13:22,
archived)
int funkydiv (int a, int b) {
if(b == 0) return MAX; else return a/b;
}
so long as you make sure it's distinguished from the built-in int type. also, i don't know what c's like for overloading operators, but it'd be a piece of piss to overload the division operator in c++