Discuss Scratch
- Scratch-Coding
-
500+ posts
0 / 0
Why does calculating 0 / 0 make NAN? What is the answer of 0/0?
Last edited by Scratch-Coding (Sept. 17, 2019 22:57:32)
- D-ScratchNinja
-
1000+ posts
0 / 0
While any other number divided by zero is infinity, I think the result of 0 / 0 is both zero and infinity, so NaN could be used to represent the paradox.
- Flowermanvista
-
1000+ posts
0 / 0
Mathematically, division by zero is undefined. So, technically, NaN, which means Not a Number, is correct, because undefined is not a number.
- NilsTheBest
-
1000+ posts
0 / 0
It returns “Nan” by dividing any number at all by zero. You can't divide by zero. If you pay attention, you'll notice that when you try to divide any number by zero on your calculator, it returns “error” or something like that.
From what I understand from a research I did a while ago, dividing by 0 seems to be infinity, which isn't a number. Infinity is a.. concept, not a number? If it was 0, it would display “0”, not “Nan”. But that's just my theory (✧≖╭͜ʖ╮≖) While any other number divided by zero is infinity, I think the result of 0 / 0 is both zero and infinity, so NaN could be used to represent the paradox.
Last edited by NilsTheBest (Aug. 21, 2019 00:47:17)
- UnconstructivePoster
-
100+ posts
0 / 0
0 divided by 0 could be any number, because any number times 0 equals 0. That's why it's undefined. snippyFrom what I understand from a research I did a while ago, dividing by 0 seems to be infinity, which isn't a number. Infinity is a.. concept, not a number? If it was 0, it would display “0”, not “Nan”. But that's just my theory (✧≖╭͜ʖ╮≖) While any other number divided by zero is infinity, I think the result of 0 / 0 is both zero and infinity, so NaN could be used to represent the paradox.
- NilsTheBest
-
1000+ posts
0 / 0
Take 15. Divide it by 3.0 divided by 0 could be any number, because any number times 0 equals 0. That's why it's undefined. snippyFrom what I understand from a research I did a while ago, dividing by 0 seems to be infinity, which isn't a number. Infinity is a.. concept, not a number? If it was 0, it would display “0”, not “Nan”. But that's just my theory (✧≖╭͜ʖ╮≖) While any other number divided by zero is infinity, I think the result of 0 / 0 is both zero and infinity, so NaN could be used to represent the paradox.
You take 3, you get 12.
You take 3, you get 9.
{…}
You take 3, you get 0.
You “took 3” 5 times, so 15 / 3 = 5.
Now take a number like 42.
You take 0, you get 42.
You take 0, you get 42.
{…}
You take 0, you get 42.
You take 0, you get 42.
It doesn't really seem to be taking us anywhere. You're “taking 0” an infinite amount of times.
So x / 0 = ∞ ?
Last edited by NilsTheBest (Aug. 21, 2019 01:15:24)
- UnconstructivePoster
-
100+ posts
0 / 0
If a / b = c, c * b = a. And if a * b = c, c / b = a.Take 15. Divide it by 3.0 divided by 0 could be any number, because any number times 0 equals 0. That's why it's undefined. snippyFrom what I understand from a research I did a while ago, dividing by 0 seems to be infinity, which isn't a number. Infinity is a.. concept, not a number? If it was 0, it would display “0”, not “Nan”. But that's just my theory (✧≖╭͜ʖ╮≖) While any other number divided by zero is infinity, I think the result of 0 / 0 is both zero and infinity, so NaN could be used to represent the paradox.
You take 3, you get 12.
You take 3, you get 9.
{…}
You take 3, you get 0.
You “took 3” 5 times, so 15 / 3 = 5.
Now take a number like 42.
You take 0, you get 42.
You take 0, you get 42.
{…}
You take 0, you get 42.
You take 0, you get 42.
It doesn't really seem to be taking us anywhere. You're “taking 0” an infinite amount of times.
So x / 0 = ∞ ?
Let's say 0 / 0 = x. Then x * 0 = 0.
But any value of x works. 1, 509, -1928.5, pi, anything. Since anything * 0 = 0, 0 / 0 could equal anything.
But nobody likes this scenario, so 0 / 0 is called an indeterminate form.
Last edited by UnconstructivePoster (Aug. 21, 2019 01:21:43)
- UnconstructivePoster
-
100+ posts
0 / 0
*sorry, should've said undefined bleh
But nobody likes this scenario, so 0 / 0 is called an *indeterminate form.
indeterminate forms are for limits
new scratchers and post editing
Last edited by UnconstructivePoster (Aug. 21, 2019 01:25:29)
- -Reshiram-
-
100+ posts
0 / 0
Here's my theory:Take 15. Divide it by 3.0 divided by 0 could be any number, because any number times 0 equals 0. That's why it's undefined. snippyFrom what I understand from a research I did a while ago, dividing by 0 seems to be infinity, which isn't a number. Infinity is a.. concept, not a number? If it was 0, it would display “0”, not “Nan”. But that's just my theory (✧≖╭͜ʖ╮≖) While any other number divided by zero is infinity, I think the result of 0 / 0 is both zero and infinity, so NaN could be used to represent the paradox.
You take 3, you get 12.
You take 3, you get 9.
{…}
You take 3, you get 0.
You “took 3” 5 times, so 15 / 3 = 5.
Now take a number like 42.
You take 0, you get 42.
You take 0, you get 42.
{…}
You take 0, you get 42.
You take 0, you get 42.
It doesn't really seem to be taking us anywhere. You're “taking 0” an infinite amount of times.
So x / 0 = ∞ ?
Let's use the expression x / y.
Let's also set x to 1.
1 / 1 = 1.
1 / 0.1 = 10.
1 / 0.01 = 100.
[…]
1 / 0.000000000001 = 1,000,000,000,000.
As you can see, as the divisor gets smaller, the quotient gets larger.
If we make the divisor infinitely small, will the answer be infinitely large?
x / 0 = ∞?
Last edited by -Reshiram- (Aug. 21, 2019 01:36:51)
- DaEpikDude
-
1000+ posts
0 / 0
I'm just going to nerd out for a second here and say that x/0 is +infinity and -infinity at the same time, so it doesn't have a value.
If you start with 1/1, then go 1/0.1, 1/0.01, 1/0.0000001 etc. then yes, the number gets larger and larger and shoots off to infinity.
However, start with 1/-1, 1/-0.1, 1/-0.01 etc., you still end up with 1/0 but this time the number goes down to negative infinity.
So 1/0 is +infinity and -infinity at the same time?
I believe 0/0 can be basically whatever you want it to be. For example:
2/1
1/0.5
0.5/0.25
0.25/0.125
0.125/0.0625
…
All of those equal 2, but you'll eventually get to 0/0.
Now:
1/1
0.5/0.5
0.25/0.25
0.125/0.125
…
All of those equal 1, but you'll still eventually get to 0/0.
So you can't give 0/0 a value: it's “undefined”.
I mean, differentiation in calculus is basically just 0/0 if you think about it, but that gives you all sorts of perfectly sensible derivatives.
For the actual question at hand, I think the “NaN” is probably just from Javascript, since that's what Javascript gives you when you do 0/0.
(I like how Javascript treats “not a number” as a perfectly normal number that just happens to give you itself whenever you do an operation with it)
If you start with 1/1, then go 1/0.1, 1/0.01, 1/0.0000001 etc. then yes, the number gets larger and larger and shoots off to infinity.
However, start with 1/-1, 1/-0.1, 1/-0.01 etc., you still end up with 1/0 but this time the number goes down to negative infinity.
So 1/0 is +infinity and -infinity at the same time?
I believe 0/0 can be basically whatever you want it to be. For example:
2/1
1/0.5
0.5/0.25
0.25/0.125
0.125/0.0625
…
All of those equal 2, but you'll eventually get to 0/0.
Now:
1/1
0.5/0.5
0.25/0.25
0.125/0.125
…
All of those equal 1, but you'll still eventually get to 0/0.
So you can't give 0/0 a value: it's “undefined”.
I mean, differentiation in calculus is basically just 0/0 if you think about it, but that gives you all sorts of perfectly sensible derivatives.
For the actual question at hand, I think the “NaN” is probably just from Javascript, since that's what Javascript gives you when you do 0/0.
(I like how Javascript treats “not a number” as a perfectly normal number that just happens to give you itself whenever you do an operation with it)
- WindOctahedron
-
1000+ posts
0 / 0
Actually, because anything divided by itself is 1, 0/0 should also be 1.
But we already have so many answers and explanations to them that I think that we should all agree on DaEpikDude's “0/0 is subjective”.
But we already have so many answers and explanations to them that I think that we should all agree on DaEpikDude's “0/0 is subjective”.
Last edited by WindOctahedron (Aug. 21, 2019 08:24:49)
- DipLeChip
-
1000+ posts
0 / 0
Actually, because anything divided by itself is 1, 0/0 should also be 1.
hold on big brain time.
That's not true, for you see dividing 4 by 4 splitting 4 into a fourth of itself, which is 1. 0/0 is spliting 0 into a zeroth(?) of itself, which is of course doesnt align so would be NaN or 0
which is also why anything divided by 0 is 0 or NaN
Last edited by DipLeChip (Aug. 21, 2019 09:33:55)
- Dragonlord767
-
1000+ posts
0 / 0
Can we get this back on topic? This thread is not to discuss what 0/0 is.
- kenny2scratch
-
500+ posts
0 / 0
To sum up, 0/0 in JavaScript returns NaN because that's the most mathematically accurate answer that JS wants to provide. Can we get this back on topic? This thread is not to discuss what 0/0 is.
In Python, dividing by zero actually raises an exception specifically tailored to that scenario:
>>> 0/0 Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> 0/0 ZeroDivisionError: division by zero
Similarly, division by zero in C:
#include <stdio.h> int main() { return 0/0; }
divzero.c: In function ‘main’:
divzero.c:4:10: warning: division by zero [-Wdiv-by-zero]
return 0/0;
^
Floating point exception (core dumped)
However, Python also has a NaN value:
>>> float('nan') nan
which is the result of some operations on infinity:
>>> float('inf') - float('inf') nan >>> float('inf') + float('-inf') nan >>> float('inf') / float('inf') nan
but is not the result of division by zero.
- -Reshiram-
-
100+ posts
0 / 0
Yes, but that means However, start with 1/-1, 1/-0.1, 1/-0.01 etc., you still end up with 1/0 but this time the number goes down to negative infinity.x / -0 = -∞.

- WaterComesBack
-
100+ posts
0 / 0
0 is a neutral number, so -0 does not existYes, but that means However, start with 1/-1, 1/-0.1, 1/-0.01 etc., you still end up with 1/0 but this time the number goes down to negative infinity.x / -0 = -∞.

- kenny2scratch
-
500+ posts
0 / 0
-0 doesn't, but -0.0 does, at least when it comes to Python0 is a neutral number, so -0 does not existYes, but that means However, start with 1/-1, 1/-0.1, 1/-0.01 etc., you still end up with 1/0 but this time the number goes down to negative infinity.x / -0 = -∞.

>>> 0 0 >>> -0 0 >>> 0.0 0.0 >>> -0.0 -0.0
- CatsUnited
-
1000+ posts
0 / 0
That's most likely just due to how floating point numbers work in programming languages, since in proper programming languages, integers and floating point numbers are two different data types which you don't have to worry about in Scratch.-0 doesn't, but -0.0 does, at least when it comes to Python0 is a neutral number, so -0 does not existYes, but that means However, start with 1/-1, 1/-0.1, 1/-0.01 etc., you still end up with 1/0 but this time the number goes down to negative infinity.x / -0 = -∞.>>> 0 0 >>> -0 0 >>> 0.0 0.0 >>> -0.0 -0.0
- kenny2scratch
-
500+ posts
0 / 0
Yes, yes, in Python it's specifically that the float class is at its root a C double, and the IEEE standard for floats and doubles is sign, magnitude, and exponent - which means that you can have a 0.0: -snip-
That's most likely just due to how floating point numbers work in programming languages, since in proper programming languages, integers and floating point numbers are two different data types which you don't have to worry about in Scratch.
0 00000000 00000000000000000000000
s exponent mantissaaaaaaaaaaaaaaa
1 00000000 00000000000000000000000
s exponent mantissaaaaaaaaaaaaaaa
>>> 0.0 * 3 0.0 >>> -0.0 * 3 -0.0 >>> 0.0 < 0 False >>> -0.0 < 0 False >>> 0.0 > 0 False >>> -0.0 > 0 False >>> 0.0 / 1 0.0 >>> -0.0 / 1 -0.0 >>> 1 / 0.0 Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> 1 / 0.0 ZeroDivisionError: float division by zero >>> 1 / -0.0 Traceback (most recent call last): File "<pyshell#9>", line 1, in <module> 1 / -0.0 ZeroDivisionError: float division by zero