bit manipulation - abs function for float value in java -
i need create function abs float bitwise operators, function homecoming float value.
i can't utilize <
or >
.
i seek
(float)((int)f ^ ((int)f>>31)) - ((int)f>>31)
but -2.5
value 2.0
, it's not correct.
can help me?
you can this
float abs = float.intbitstofloat(float.floattointbits(x) & 0x7fffffff);
java bit-manipulation bitwise-operators
No comments:
Post a Comment