Discuss Scratch

ThunderNox
Scratcher
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:
absof9
but it only turns negative numbers into positive and not the other way. Please Help!
PutneyCat
Scratcher
500+ posts

How to turn a positive value into a negative

setpositive numto-positivenum

or if you want to be able to keep negative numbers as negative, and turn positive numbers into negative:

setany numberto-absofanynumber

Last edited by PutneyCat (April 26, 2020 16:56:39)

GuineaGod
Scratcher
500+ posts

How to turn a positive value into a negative

PutneyCat wrote:

setpositive numto-positivenum

or if you want to be able to keep negative numbers as negative, and turn positive numbers into positive:

setany numberto-absofanynumber

???
You make it so that ANY number minus its absoluted value, (abs) is the same???
Catscratcher07
Scratcher
1000+ posts

How to turn a positive value into a negative

just multiple by -1
PutneyCat
Scratcher
500+ posts

How to turn a positive value into a negative

GuineaGod wrote:

PutneyCat wrote:

setpositive numto-positivenum

or if you want to be able to keep negative numbers as negative, and turn positive numbers into positive:

setany numberto-absofanynumber

???

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
Scratcher
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
Scratcher
500+ posts

How to turn a positive value into a negative

rayli1123 wrote:

You should multiply the number by -1

Oh YES! you are right. for all code and varibles, they differ from 1 to -1

whenclickedforeversayYES!
ThunderNox
Scratcher
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!
CoolGuyz777
Scratcher
14 posts

How to turn a positive value into a negative

Very easy
anynumber*-1
wvj
Scratcher
1000+ posts

How to turn a positive value into a negative

or

setvarto0-var
goldenlion06
Scratcher
500+ posts

How to turn a positive value into a negative

OR
setvartojoin-var
barcode2
Scratcher
12 posts

How to turn a positive value into a negative

setnumbertonumber*-1
TheAnomalousPseudo
Scratcher
1000+ posts

How to turn a positive value into a negative

barcode2 wrote:

setnumbertonumber*-1
Please don't necropost. The original post is over a year old.

Powered by DjangoBB