Discuss Scratch
- Discussion Forums
- » Suggestions
- » Dividing by zero should result in a NaN not infinity.
- RedNeckSideKick
-
Scratcher
67 posts
Dividing by zero should result in a NaN not infinity.
Hey all! Recently I found out that dividing anything by 0 returns infinity, not the not a number that it should return. This is REALLY making it hard to program things that use complex(ish) math.
I hope this “problem” is sorted out soon!
(P.S. My browser / operating system: MacOS Macintosh X 10.8.5, Safari 6.1.5, Flash 14.0 (release 0), if it helps…)
I hope this “problem” is sorted out soon!

(P.S. My browser / operating system: MacOS Macintosh X 10.8.5, Safari 6.1.5, Flash 14.0 (release 0), if it helps…)
- djdolphin
-
Scratcher
1000+ posts
Dividing by zero should result in a NaN not infinity.
Not everything - 0/0 gives you NaN.
- TheHockeyist
-
Scratcher
1000+ posts
Dividing by zero should result in a NaN not infinity.
Support. Or have a funny error.
forever
when I divide by zero :: events
say [OH NOES! YOU DIVIDED BY ZERO! SCRATCH IS GOING TO END!]
*weird effects that sound like the entire website will crash on you*
end
- TimothyLawyer
-
Scratcher
1000+ posts
Dividing by zero should result in a NaN not infinity.
This is REALLY making it hard to program things that use complex(ish) math.Could you give some examples?
- PH-zero
-
Scratcher
100+ posts
Dividing by zero should result in a NaN not infinity.
Support!!!
Infinity is an idea, and not a number…
oh… infinity is not a number xD
But seriously, it should really result in NaN.
Infinity is an idea, and not a number…
oh… infinity is not a number xD
But seriously, it should really result in NaN.
- AonymousGuy
-
Scratcher
1000+ posts
Dividing by zero should result in a NaN not infinity.
I thought it some definitions of mathematics x / 0 = infinity, probably because as y approaches 0 in x / y, x becomes larger.
And there's technically a workaround:
And there's technically a workaround:
define divide (num1) by (num2)
if <(num2) = [0]> then
set [return v] to [NaN]
else
set [return v] to ((num1) / (num2))
end
- turkey3
-
Scratcher
1000+ posts
Dividing by zero should result in a NaN not infinity.
I like infinity. If you think of how in x / y you can count up y by going y + y + y until you reach x. But with zero you can keep counting 0 + 0 + 0 + 0 on for infinity and never get to the divisor.
- lalala3
-
Scratcher
100+ posts
Dividing by zero should result in a NaN not infinity.
I thought it some definitions of mathematics x / 0 = infinity, probably because as y approaches 0 in x / y, x becomes larger.That's wrong. Let me explain. Assuming, for convenience, that x is positive, that's true as y approaches zero but is positive, but if y is negative, then x / y is a large negative number. So, what's the result of something divided by zero? Is it positive or negative infinity? That's the problem with saying that something divided by zero is infinity.
You could also think of it like this: any number divided by zero is not infinity, because if you multiplied zero by infinity, you wouldn't get the original number; you'd just get zero.
- Julianthewiki
-
Scratcher
100+ posts
Dividing by zero should result in a NaN not infinity.
Not everything - 0/0 gives you NaN.I bet 0/0=0, as 0*0=0.

- lalala3
-
Scratcher
100+ posts
Dividing by zero should result in a NaN not infinity.
No, obviously 0/0=9, because 9*0=0.Not everything - 0/0 gives you NaN.I bet 0/0=0, as 0*0=0.
- TheHockeyist
-
Scratcher
1000+ posts
Dividing by zero should result in a NaN not infinity.
0/0 is everything. everything*0 = 0.
Last edited by TheHockeyist (Aug. 10, 2014 21:02:16)
- seanbobe
-
Scratcher
500+ posts
Dividing by zero should result in a NaN not infinity.
noNo, obviously 0/0=9, because 9*0=0.Not everything - 0/0 gives you NaN.I bet 0/0=0, as 0*0=0.
0/0=3.1415926… because 3.1415926…*0=0
- MrNanners
-
Scratcher
100+ posts
Dividing by zero should result in a NaN not infinity.
No support. Just read infinity as not a number.
if <not<<((1)/(variable))=[Infinity]> or <((1)/(variable))=[NaN]>>> then
end
- reallysoftuser
-
Scratcher
1000+ posts
Dividing by zero should result in a NaN not infinity.
Guys, this is just how the language works… Also it's useful in scenarios where you need a “infinity” value.
- dave-alt-4
-
Scratcher
1000+ posts
Dividing by zero should result in a NaN not infinity.
no support , that'll break all projects using the 1/0 as infinity , also , whats wrong with infinity? u can code it into NaN anyways
- CoolBoy4286
-
Scratcher
100+ posts
Dividing by zero should result in a NaN not infinity.
No support, I think the reason that dividing by 0 returns infinity is because you can go 0+0+0+0+0… infinite times and you'll never get to the number that you're dividing.
- Virus6120
-
Scratcher
100+ posts
Dividing by zero should result in a NaN not infinity.
No support, I think the reason that dividing by 0 returns infinity is because you can go 0+0+0+0+0… infinite times and you'll never get to the number that you're dividing.Except the whole point of division is that repeated addition of the divisor times eventually results in the dividend. 0+0+0+0+0 will never reach any number, even if you add it infinite times. Returning infinity would imply that after adding 0 infinity times you will reach the dividend, which is often not the case!
Now for how computers do division, it's a rather computationally heavy process involving repeated subtraction, hence in the case of a divisor of 0 it would keep trying to subtract 0 from the number (which doesn't do anything), hence infinity sort of makes sense.
- 6d66yh
-
Scratcher
100+ posts
Dividing by zero should result in a NaN not infinity.
No support. Just read infinity as not a number.If variable is set to -0 it will pass through because 1÷-0=-Infinity.if <not<<((1)/(variable))=[Infinity]> or <((1)/(variable))=[NaN]>>> then
end
- BJ273
-
Scratcher
84 posts
Dividing by zero should result in a NaN not infinity.
Scratch is coded in JavaScript, and unfortunately, 0/0 in JS returns NaN, and anything else/0 returns infinity. Don't ask why, it just does (I just checked). So JavaScript gets the same results as scratch, because scratch is coded in JS, scratch is just running by JS rules. So sadly, it is best to just find a workaround unless you want scratch to rewrite JS so they can fix a small problem.
- Discussion Forums
- » Suggestions
-
» Dividing by zero should result in a NaN not infinity.
















