Comparing floats in their bit representations

Posted by sczizzo on Stack Overflow See other posts from Stack Overflow or by sczizzo
Published on 2010-04-06T03:02:57Z Indexed on 2010/04/06 3:13 UTC
Read the original article Hit count: 213

Filed under:
|
|

Say I want a function that takes two floats (x and y), and I want to compare them using not their float representation but rather their bitwise representation as a 32-bit unsigned int. That is, a number like -495.5 has bit representation 0b11000011111001011100000000000000 or 0xC3E5C000 as a float, and I have an unsigned int with the same bit representation (corresponding to a decimal value 3286614016, which I don't care about). Is there any easy way for me to perform an operation like <= on these floats using only the information contained in their respective unsigned int counterparts?

© Stack Overflow or respective owner

Related posts about c

    Related posts about c++