Discuss Scratch

Kami-ko
Scratcher
100+ posts

Normalization of a number in Scratch

QUICK TIP:

I don't know if anyone has mentioned this already, but there's a pretty simple way of getting the normalized value (scales value to -1, 0, or 1) of a number in Scratch. Simply use
number/absofnumber

and … that's it!
SimpleScratch
Scratcher
500+ posts

Normalization of a number in Scratch

Doesn't work if number = 0
Kami-ko
Scratcher
100+ posts

Normalization of a number in Scratch

It's not that advanced, but I wanted to let you guys know; hopefully this can help one of you
Kami-ko
Scratcher
100+ posts

Normalization of a number in Scratch

SimpleScratch wrote:

Doesn't work if number = 0
0 would equal 0
badatprogrammingibe
Scratcher
500+ posts

Normalization of a number in Scratch

That's an implementation of signum, not an implementation of normalisation. Even so, SimpleScratch is right in that it doesn't work with 0.
Sheep_maker
Scratcher
1000+ posts

Normalization of a number in Scratch

n/1+absofn
should work with n = 0. It has a range of (-1, 1)
XayCraft360
Scratcher
100+ posts

Normalization of a number in Scratch

Sheep_maker wrote:

n/1+absofn
should work with n = 0. It has a range of (-1, 1)
if you think about it, it wouldn't work with numbers greater than 0. For example, 2 would give 2/3
Kami-ko
Scratcher
100+ posts

Normalization of a number in Scratch

badatprogrammingibe wrote:

That's an implementation of signum, not an implementation of normalisation. Even so, SimpleScratch is right in that it doesn't work with 0.
That's right haha, got my terms mixed up.
Monna-Uka
Scratcher
1000+ posts

Normalization of a number in Scratch

How about:
n/absofn*n=0Infinity on Scratch = n/0 and maybe Infinity*0 = 0?
Monna-Uka
Scratcher
1000+ posts

Normalization of a number in Scratch

Monna-Uka wrote:

How about:
n/absofn*notn=0Infinity on Scratch = n/0 and maybe Infinity*0 = 0?
--Explosion--
Scratcher
1000+ posts

Normalization of a number in Scratch

Frankly, this seems sorta obvious…
1132262
Scratcher
1000+ posts

Normalization of a number in Scratch

XayCraft360 wrote:

Sheep_maker wrote:

n/1+absofn
should work with n = 0. It has a range of (-1, 1)
if you think about it, it wouldn't work with numbers greater than 0. For example, 2 would give 2/3
Easy.
n/absofn*absofn>0

Last edited by 1132262 (March 4, 2020 23:57:44)

1132262
Scratcher
1000+ posts

Normalization of a number in Scratch

--Explosion-- wrote:

Frankly, this seems sorta obvious…
You underestimate the time we spend trying to get all of our code to fit into one expression.
--Explosion--
Scratcher
1000+ posts

Normalization of a number in Scratch

SimpleScratch wrote:

Doesn't work if number = 0
It should, 0/0 is 1.
1132262
Scratcher
1000+ posts

Normalization of a number in Scratch

--Explosion-- wrote:

SimpleScratch wrote:

Doesn't work if number = 0
It should, 0/0 is 1.
No…
Monna-Uka
Scratcher
1000+ posts

Normalization of a number in Scratch

--Explosion-- wrote:

SimpleScratch wrote:

Doesn't work if number = 0
It should, 0/0 is 1.
x/0 in Scratch is equal to infinity. I know it because I have used this to pause the playing music.
NickyNouse
Scratcher
1000+ posts

Normalization of a number in Scratch

Yeah, Scratch (both 2 and 3) use a number standard called IEEE 754, which defines 1/0 as the special value Infinity and -1/0 as -Infinity.
Maximouse
Scratcher
1000+ posts

Normalization of a number in Scratch

--Explosion-- wrote:

SimpleScratch wrote:

Doesn't work if number = 0
It should, 0/0 is 1.

0/0 is undefined (NaN in Scratch). 1/0 is infinity.

Powered by DjangoBB