## Instruction to set a negative number to positive

Find quick help here to get you started with Hollywood
Juan Carlos
Posts: 692
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

### Instruction to set a negative number to positive

Which is the instruction to convert a negative number to positive? And viceversa.
The example -3 to 3.

emeck
Posts: 94
Joined: Fri Apr 03, 2015 3:17 pm

### Re: Instruction to set a negative number to positive

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.13
PowerBook 5.8 MorphOS 3.13
Amiga 1200 BPPC/BVision AOS4.1 FE

Juan Carlos
Posts: 692
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

### Re: Instruction to set a negative number to positive

Yes, it works, thank you for your help.

zylesea
Posts: 207
Joined: Tue Feb 16, 2010 12:50 am
Location: Westfalen/Germany
Contact:

### Re: Instruction to set a negative number to positive

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)
``````