bit manipulation - abs function for float value in java -
I need to create a function abs for the float with a beta operator, this function return float value.
I & lt;
or & gt;
can not be used.
I try this
(float) ((int) f ^ ((int) f> 31)) - ((int) f & gt; ;> 31)
but for -2.5
get value I 2.0
, this is not correct.
Can you help me?
you can do this
float bf = float. BitToFlot (float.floatioidbits (x) and 0x7FFFFFFF);
Comments
Post a Comment