Which is the instruction to convert a negative number to positive? And viceversa.
The example -3 to 3.
Instruction to set a negative number to positive
- Juan Carlos
- Posts: 891
- Joined: Mon Sep 06, 2010 1:02 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
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
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
- Juan Carlos
- Posts: 891
- Joined: Mon Sep 06, 2010 1:02 pm
Re: Instruction to set a negative number to positive
Yes, it works, thank you for your help.
Re: Instruction to set a negative number to positive
Just use the - operatorJuan 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.
Code: Select all
i=-3
i=-i
DebugPrint("i= ",i)