b3ta.com board
You are not logged in. Login or Signup
Home » Messageboard » Message 8532339 (Thread)

# you can't make me it's undefined. And that is a perfect universal truth!*
www.xkcd.com/263/

*until it is defined somehow
(, Sun 6 Jul 2008, 12:17, archived)
# I don't get how it's undefined,
are people not smart enough to figure out what it is?
(, Sun 6 Jul 2008, 12:20, archived)
# well it doesn't actually make sense, so it can't have a definition
consider the expression 1/x
it's all good for all x real. Except x identically zero at which point it is infinite. just think about x becoming smaller and smaller 1.x becomes larger and larger and finally unboundedly large.

ed: the division by zero can be admitted on the extended real line:

en.wikipedia.org/wiki/Defined_and_undefined
(, Sun 6 Jul 2008, 12:28, archived)
# The tendency of computers to barf on division by zero is intensely irritating when programming
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)
# Is there no alternative?
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)
# Pretty much.
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)
# Bah.
That sounds thrilling.
(, Sun 6 Jul 2008, 12:43, archived)
# bloody programmers :P
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 think that causes portability problems
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)
# there's no harm in writing your own library that does a manual test
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)
# Fair point.
(, Sun 6 Jul 2008, 13:27, archived)
# i write infrastructure for dsp engineers sometimes
they can be fussy about their maths
(, Sun 6 Jul 2008, 13:38, archived)
# the word "pretend" is your answer, i think
if you want a reliably correct result you're going to have to write code that actually handles div 0, rather than an approximation, and that kind of depends on the processor telling you that it's happened
(, Sun 6 Jul 2008, 13:02, archived)
# So you're basically saying that there is an infinate numebr of zeros in any one number, of any size?
Because that makes perfect sense.
(, Sun 6 Jul 2008, 12:36, archived)
# yes and it does make sense....
but because it's late and I'm still hungover it's not the reason it's undefined:

In this, the graph is 1/x and lt means limit. As the you get very small from the positive side, you tend to infinity but as you get very small from the negative side you tend to negative infinity. so you end up in a pickle, sorry for the shoddy explaination the first time...
(, Sun 6 Jul 2008, 12:44, archived)
# I like your handwriting
(, Sun 6 Jul 2008, 12:47, archived)
# that's odd
no one else does...
(, Sun 6 Jul 2008, 12:51, archived)
# Mine's awful :P
I'm trying to write a letter and I have to concentrate really hard to make it legible.
Letter writing usually takes me all day.
(, Sun 6 Jul 2008, 12:52, archived)
# type it?
(, Sun 6 Jul 2008, 12:54, archived)
# But it's a personal letter to my pen pal!
(, Sun 6 Jul 2008, 12:56, archived)
# Oh, I see.
Would it help if I specified whether I was dividing by positive or negative zero?
(, Sun 6 Jul 2008, 12:49, archived)
# that's the problem
+0 = -0
(, Sun 6 Jul 2008, 12:51, archived)
# Well let's say it doesn't.
(That would make -0 into 11111110 as a signed byte, I'm not sure whether that already means something or not, I think perhaps it's up for grabs.)
(, Sun 6 Jul 2008, 12:52, archived)
# Shit man, you're deep...
(, Sun 6 Jul 2008, 12:53, archived)
# aaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhh
(, Sun 6 Jul 2008, 12:54, archived)