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

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -