How can I change the sign of an Integer value like 100 to -100 ?

A

Andreas Klemt

Hello,
how can I change the sign of an Integer Value like

Abs?(100)
-> -100

Thanks,
Andreas
 
K

Karl Seguin

multiple by -1 will always toggle the sign...

-1 * 40 = -40
-1 * -40 = 40

abs() will always make something positive

abs(40) = 40
abs(-40) = 40

abs() * -1 will always make it negative

abs(40) * -1 = -40
abs(-40) * -1 = 40

(abs is defined in system.math)

karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top