Discuss Scratch

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…)
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.

RedNeckSideKick wrote:

This is REALLY making it hard to program things that use complex(ish) math.
Could you give some examples?

BeetleBlocks, WatercolorBot, and Turtle Art
Hover over a name or label to translate into current language
When Earth was… Purple?

☂️




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.

Ever wanted to rotate the stage? Or to
go to x:() y:() z:() ::custom
Click me!
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:
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.

AonymousGuy wrote:

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.

djdolphin wrote:

Not everything - 0/0 gives you NaN.
I bet 0/0=0, as 0*0=0.

Julianthewiki | Double the Fun | Double the Thrill | Double the Coolness

Daydream: A Book By Julianthewiki | Official Studio | Chapter 1 | Chapter 2 | Chapter 3
World Population Clock | 24,618,660 | Learn More | Suggest Ideas
Two Year Anniversary Special | 101,405,320 | Learn More
Belated Happy Pi Day! | 102,312,109
lalala3
Scratcher
100+ posts

Dividing by zero should result in a NaN not infinity.

Julianthewiki wrote:

djdolphin wrote:

Not everything - 0/0 gives you NaN.
I bet 0/0=0, as 0*0=0.
No, obviously 0/0=9, because 9*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.

lalala3 wrote:

Julianthewiki wrote:

djdolphin wrote:

Not everything - 0/0 gives you NaN.
I bet 0/0=0, as 0*0=0.
No, obviously 0/0=9, because 9*0=0.
no
0/0=3.1415926… because 3.1415926…*0=0

Sadly my kumquat was eaten by an evil signature.
_______________
|My internets.…..|
\Kumquat Shield/
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

That's about it, see yah.
My best and most helpful projects:
Savable Games Engine | Plants Vs. Zombies | Competitive Clicker Game
As a kid, John Lennon, member of the most successful band in history, the Beatles, said, “When I grow up, I want to be happy.” The teachers around him said that he didn't understand the question, but young John said that {the teachers} didn't understand life.
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

guide to make good projects <3


Think! Is saying if you support a suggestion necessary? No! People can just tell by your constructive post after it. You have more freedom on your tone!
Forumers, especially new, may also get upset if you say “no support!!!” at them! They may take the whole post in a negative tone, and that makes them upset!
Instead, you can kindly say why their suggestion has cons. They will take it as “constructive criticism” and be happy. - dertermenter


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.

01001110 01100101 01110110 01100101 01110010 00100000 01100111 01101111 01101110 01101110 01100001 00100000 01100111 01101001 01110110 01100101 00100000 01111001 01101111 01110101 00100000 01110101 01110000 if you translate this,


Virus6120
Scratcher
100+ posts

Dividing by zero should result in a NaN not infinity.

CoolBoy4286 wrote:

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.

Welcoming all contributors, explorers, and kumquats

Heya there, I'm currently doing some renovations to my signature, but you're welcome to stay if you like.
6d66yh
Scratcher
100+ posts

Dividing by zero should result in a NaN not infinity.

MrNanners wrote:

No support. Just read infinity as not a number.
if <not<<((1)/(variable))=[Infinity]> or <((1)/(variable))=[NaN]>>> then

end
If variable is set to -0 it will pass through because 1÷-0=-Infinity.

Integer arithmetic suggestion: https://scratch.mit.edu/discuss/post/5163608/
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.

Powered by DjangoBB