Discuss Scratch
- Discussion Forums
- » Questions about Scratch
- » Converting negative into positive and vice versa
- GT1016
-
11 posts
Converting negative into positive and vice versa
What operator or script could turn, say, -3 into 3, 4 into -4, 129 into -129, etc.? I'm using this to make inverted movement. Thanks!
- Za-Chary
-
1000+ posts
Converting negative into positive and vice versa
Another option is:
((0) - ())
- Zydrolic
-
1000+ posts
Converting negative into positive and vice versa
And if you have an edgecase where you exclusively want to convert negative to positive, use absolute value: Another option is:((0) - ())
([abs v] of ())
- Scratch137
-
1000+ posts
Converting negative into positive and vice versa
(#5)And, to complete the family, you can multiply the absolute value by -1 or subtract it from 0 to convert only positive numbers to negative numbers:And if you have an edgecase where you exclusively want to convert negative to positive, use absolute value: Another option is:((0) - ())([abs v] of ())
(([abs v] of ()) * (-1))
((0) - ([abs v] of ()))
- Discussion Forums
- » Questions about Scratch
-
» Converting negative into positive and vice versa