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

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

Andreas Klemt
Guest
Posts: n/a

 07-28-2003
Hello,
how can I change the sign of an Integer Value like

Abs?(100)
-> -100

Thanks,
Andreas

Karl Seguin
Guest
Posts: n/a

 07-28-2003
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

"Andreas Klemt" <(E-Mail Removed)> wrote in message
news:e%(E-Mail Removed)...
> Hello,
> how can I change the sign of an Integer Value like
>
> Abs?(100)
> -> -100
>
> Thanks,
> Andreas
>
>

Marina
Guest
Posts: n/a

 07-28-2003
Multiply it by -1.

"Andreas Klemt" <(E-Mail Removed)> wrote in message
news:e%(E-Mail Removed)...
> Hello,
> how can I change the sign of an Integer Value like
>
> Abs?(100)
> -> -100
>
> Thanks,
> Andreas
>
>

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post jononanon@googlemail.com C Programming 5 04-25-2012 08:49 PM Abhishek C Programming 12 01-30-2006 03:22 PM fred Javascript 3 03-17-2005 04:25 AM