Instruction to set a negative number to positive

Find quick help here to get you started with Hollywood
Post Reply
User avatar
Juan Carlos
Posts: 889
Joined: Mon Sep 06, 2010 1:02 pm

Instruction to set a negative number to positive

Post by Juan Carlos »

Which is the instruction to convert a negative number to positive? And viceversa.
The example -3 to 3.
User avatar
emeck
Posts: 169
Joined: Fri Apr 03, 2015 3:17 pm

Re: Instruction to set a negative number to positive

Post 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
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
User avatar
Juan Carlos
Posts: 889
Joined: Mon Sep 06, 2010 1:02 pm

Re: Instruction to set a negative number to positive

Post by Juan Carlos »

Yes, it works, thank you for your help.
zylesea
Posts: 227
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

Re: Instruction to set a negative number to positive

Post 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)
Post Reply