Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to turn a positive value into a negative
- ThunderNox
-
53 posts
How to turn a positive value into a negative
This question doesn't need much explanation. How do I turn a negative number into a positive one? I know there is the:
but it only turns negative numbers into positive and not the other way. Please Help!
- PutneyCat
-
500+ posts
How to turn a positive value into a negative
or if you want to be able to keep negative numbers as negative, and turn positive numbers into negative:
Last edited by PutneyCat (April 26, 2020 16:56:39)
- GuineaGod
-
500+ posts
How to turn a positive value into a negative
or if you want to be able to keep negative numbers as negative, and turn positive numbers into positive:
???
You make it so that ANY number minus its absoluted value, (abs) is the same???
- Catscratcher07
-
1000+ posts
How to turn a positive value into a negative
just multiple by -1
- PutneyCat
-
500+ posts
How to turn a positive value into a negative
or if you want to be able to keep negative numbers as negative, and turn positive numbers into positive:
???
You make it so that ANY number minus its absoluted value, (abs) is the same???
EDIT: I've edited my earlier post: the last word should have been “negative”.
It's “set to” rather than “change by”. I'm calling the variable “any number” to make clear the variable can be positive or negative to start with. The result will be always be negative, just as the result of “abs” is always positive.
E.g. 7 gets turned into -7, because 0 - abs(7) = 0 - 7 = -7.
And -7 stays as -7 because 0 - abs(-7) = 0 - 7 = -7.
(I've used 0-number but mutiplying by -1 achieves the same thing. 0 - n and n x -1 are both equal to -n.)
Last edited by PutneyCat (April 26, 2020 16:57:10)
- RL1123
-
1000+ posts
How to turn a positive value into a negative
You should multiply the number by -1
Last edited by RL1123 (April 26, 2020 16:56:24)
- GuineaGod
-
500+ posts
How to turn a positive value into a negative
You should multiply the number by -1
Oh YES! you are right. for all code and varibles, they differ from 1 to -1
- ThunderNox
-
53 posts
How to turn a positive value into a negative
I can't believe I just had to multiply it by -1. I feel so dumb now
Thanks!

- TheAnomalousPseudo
-
1000+ posts
How to turn a positive value into a negative
Please don't necropost. The original post is over a year old.
- Discussion Forums
- » Help with Scripts
-
» How to turn a positive value into a negative