java - Finding absolute value of a number without using Math.abs() -


is there way find absolute value of number without using math.abs() method in java.

if inside math.abs can find best answer:

eg, floats:

    /*      * returns absolute value of {@code float} value.      * if argument not negative, argument returned.      * if argument negative, negation of argument returned.      * special cases:      * <ul><li>if argument positive 0 or negative zero,      * result positive zero.      * <li>if argument infinite, result positive infinity.      * <li>if argument nan, result nan.</ul>      * in other words, result same value of expression:      * <p>{@code float.intbitstofloat(0x7fffffff & float.floattointbits(a))}      *      * @param     argument absolute value determined      * @return  absolute value of argument.      */     public static float abs(float a) {         return (a <= 0.0f) ? 0.0f - : a;     } 

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -