I know that when you divide by 0, technically the result is not a number, but this is really inconvenient.
Please change this so that it will become a 0 automatically, the distance formula keeps messing up... (and I DID put absolute values before the square roots, but I have to add 0.01 and I'm using really small sprites)
It can't be that hard... right?
Offline
You get a squeak error though because it's Squeak itself that can't handle dividing by 0, not Scratch. So it's out of the Scratch Team's hands.
Offline
I like the idea of setting anything divide by 0 to NaN (not a number) instead of crashing the program.
Offline
juststickman wrote:
I know that when you divide by 0, technically the result is not a number, but this is really inconvenient.
Please change this so that it will become a 0 automatically, the distance formula keeps messing up... (and I DID put absolute values before the square roots, but I have to add 0.01 and I'm using really small sprites)
It can't be that hard... right?
I did it online with my calculator,It said infinity or put the symbol
Offline
+0.001 still gets me close answers to what I want and doesn't make much of a difference to the calculation other than making it not infinite - so I think it's just fine.
Offline
Ace-of-Spades wrote:
You get a squeak error though because it's Squeak itself that can't handle dividing by 0, not Scratch. So it's out of the Scratch Team's hands.
Actually, if this were the case, it wouldn't. Squeak is fully self modifiable.
However, it is actually handled by scratch, using the red script thing.
As far as any programming use, it is generally most useful to assume x/0 to be infinity, unless x=0.
Squeak does support infinity.
So if anything, we should have it return infinity in the instance of dividing a number by zero.
Offline
For me, I think it should be zero.
Because 0/0 means that you have no groups and nothing to put into the groups. You should get the answer 0 because there wasn't anything in the groups.
Offline
ThePCKid wrote:
For me, I think it should be zero.
Because 0/0 means that you have no groups and nothing to put into the groups. You should get the answer 0 because there wasn't anything in the groups.
1/0 is infinity.
There are zero groups of 1, with infinity in each of them(or the one of them). Why?
1/1 = 1
1/2 = 0.5
1/(1/10) = 10
1/(1/100) = 100
1/(1/1,000,000) = 1,000,000
As the divisor gets larger, the answer swings closer to zero.
As it gets smaller, the answer gets larger.
Sometimes math is hard, I don't blame you, a nine-year kid.
Offline
Greatdane wrote:
ThePCKid wrote:
For me, I think it should be zero.
Because 0/0 means that you have no groups and nothing to put into the groups. You should get the answer 0 because there wasn't anything in the groups.1/0 is infinity.
There are zero groups of 1, with infinity in each of them(or the one of them). Why?
1/1 = 1
1/2 = 0.5
1/(1/10) = 10
1/(1/100) = 100
1/(1/1,000,000) = 1,000,000
As the divisor gets larger, the answer swings closer to zero.
As it gets smaller, the answer gets larger.
Sometimes math is hard, I don't blame you, a nine-year kid.
Offline
ThePCKid wrote:
Greatdane wrote:
ThePCKid wrote:
For me, I think it should be zero.
Because 0/0 means that you have no groups and nothing to put into the groups. You should get the answer 0 because there wasn't anything in the groups.1/0 is infinity.
There are zero groups of 1, with infinity in each of them(or the one of them). Why?
1/1 = 1
1/2 = 0.5
1/(1/10) = 10
1/(1/100) = 100
1/(1/1,000,000) = 1,000,000
As the divisor gets larger, the answer swings closer to zero.
As it gets smaller, the answer gets larger.
Sometimes math is hard, I don't blame you, a nine-year kid.
0/0 is an exception duh, if you haven't figured it out yet. http://www.wolframalpha.com/input/?i=x+ … inity}+x/0
Last edited by Greatdane (2010-03-12 21:50:13)
Offline
It's normal for divide by zero to throw an error in computer programs.
or it could output an incorrect result...
http://en.wikipedia.org/wiki/Division_by_zero#In_computer_arithmetic
http://mathworld.wolfram.com/DivisionbyZero.html
http://mathforum.org/dr.math/faq/faq.divideby0.html
You can program to avoid it:
-don't let it get to zero like someone suggested already.
-test for 0 before you divide, make it do something else if it is.
-For what I need it for, sometimes I can use multiplication by a decimal number instead:
4/8 = .5
4/4 = 1
4/2 = 2
4/0 = infinity or error
4 * .125 = .5
4 * .25 = 1
4 * .5 = 2
4 * 0 = 0
there's probably better tips for avoiding /0 errors somewhere.
Last edited by AddZero (2010-03-12 23:26:37)
Offline
For now RHY3756547's idea would work, along with the (round) block. But if they decide to change it from the "red outline of death", it should give the ∞ symbol.
Offline
hmnwilson wrote:
For now RHY3756547's idea would work, along with the (round) block. But if they decide to change it from the "red outline of death", it should give the ∞ symbol.
But infinity also causes errors.
Infinity-1=error
Infinity^2=error
Infinity=error
Infinity+0=error
Offline
juststickman wrote:
hmnwilson wrote:
For now RHY3756547's idea would work, along with the (round) block. But if they decide to change it from the "red outline of death", it should give the ∞ symbol.
But infinity also causes errors.
Infinity-1=error
Infinity^2=error
Infinity=error
Infinity+0=error
The last one should be Infinity not error <abbr title="In My Opinion">IMO</abbr>
Oops I keep forgetting HTML doesn't work in the forums
Last edited by ThePCKid (2010-03-13 10:30:48)
Offline
ThePCKid wrote:
juststickman wrote:
hmnwilson wrote:
For now RHY3756547's idea would work, along with the (round) block. But if they decide to change it from the "red outline of death", it should give the ∞ symbol.
But infinity also causes errors.
Infinity-1=error
Infinity^2=error
Infinity=error
Infinity+0=errorThe last one should be Infinity not error <abbr title="In My Opinion">IMO</abbr>
I'm just saying what happens when you put it in scratch.
Offline