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: 509
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

Instruction to set a negative number to positive

Post by Juan Carlos » 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.

User avatar
emeck
Posts: 77
Joined: Fri Apr 03, 2015 3:17 pm

Re: Instruction to set a negative number to positive

Post by emeck » Mon Aug 26, 2019 7:37 pm

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

User avatar
Juan Carlos
Posts: 509
Joined: Mon Sep 06, 2010 1:02 pm
Contact:

Re: Instruction to set a negative number to positive

Post by Juan Carlos » Tue Aug 27, 2019 2:09 pm

Yes, it works, thank you for your help.

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

Re: Instruction to set a negative number to positive

Post by zylesea » Fri Sep 06, 2019 12:21 am

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