Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Opposite of Absolute Value
- Zero0111
-
100+ posts
Opposite of Absolute Value
Since the math block if you choose ABS (Absolute Value) it makes any negative number to a positive number but is there a block that makes it so any positive number changes into a negative number? For example if the number was 3 it would turn into -3 is there a way to do that?
- TONYflashB
-
100+ posts
Opposite of Absolute Value
Just do
The 0- changes negative to positive and positive to negative.
Hope that helps![](//cdn.scratch.mit.edu/scratchr2/static/__c2809c1107e2c2715f0ec5750c3512f7__/djangobb_forum/img/smilies/smile.png)
((0) - ([abs] of (number)))
The 0- changes negative to positive and positive to negative.
Hope that helps
![](http://cdn.scratch.mit.edu/scratchr2/static/__c2809c1107e2c2715f0ec5750c3512f7__/djangobb_forum/img/smilies/smile.png)
- helloworldbyeworld
-
1000+ posts
Opposite of Absolute Value
You can also flip the sign by multiplying by -1 (it’s more understandable than 0-number for me):
That way, if the number is positive, it will flip the sign, but if not, it will leave it as it is.
(([abs v] of (your number::grey)::operators) * (-1))
That way, if the number is positive, it will flip the sign, but if not, it will leave it as it is.
Helloworldbyeworld | 1200+ posts
Have a great day
- Discussion Forums
- » Help with Scripts
-
» Opposite of Absolute Value