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

Popular posts from this blog

HTML/CSS - Automatically set height width from background image? -

php - Mysql Show Process - Sleep Commands and what to do -

c - What is the address of buf (the local variable in the main function)? -