[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
Let nothing stop you! Not even this tiny ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS


This thread has been viewed 22914 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 25, 2018 14:54:37.