[Logo]
Forums Register Login
convert Postiive number to negative..
Is there any prebuilt function in java that convert positive number to negative number ??
eg, abs() convert negative to positive.. .



something like that ? (and you can write it even shorter ...)

pascal
Unary operator -
int pos = 10;
int neg = -pos;
if you want to guarantee a negative number

Math.abs(number) * -1
 

Originally posted by Michael Dunn:
if you want to guarantee a negative number

Math.abs(number) * -1



Another smart (and handsome) rancher also suggested this here

This thread has been viewed 27614 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 14, 2018 06:35:44.