Page 1 of 1

Instruction to set a negative number to positive

Posted: Mon Aug 26, 2019 7:23 pm
by Juan Carlos
Which is the instruction to convert a negative number to positive? And viceversa.
The example -3 to 3.

Re: Instruction to set a negative number to positive

Posted: Mon Aug 26, 2019 7:37 pm
by emeck
Hello Juan Carlos,

you just need to multiply the numbre by -1. For example:

-3 * -1 = 3
3 * -1 = -3
-134 * -1 = 134

Re: Instruction to set a negative number to positive

Posted: Tue Aug 27, 2019 2:09 pm
by Juan Carlos
Yes, it works, thank you for your help.

Re: Instruction to set a negative number to positive

Posted: Fri Sep 06, 2019 12:21 am
by zylesea
Juan Carlos wrote: Mon Aug 26, 2019 7:23 pm Which is the instruction to convert a negative number to positive? And viceversa.
The example -3 to 3.
Just use the - operator

Code: Select all

i=-3
i=-i
DebugPrint("i= ",i)