Search code examples
floating-pointieee-754ieee

Can IEEE 754 floating-point numbers represent the exact same value with multiple bit arrangements?


Can IEEE 754 floating-point numbers represent the exact same value with multiple bit arrangements?

For example:
128 exp 3 == 1024.0
256 exp 2 == 1024.0
1024 exp 0 == 1024.0

Does the IEEE 754 standard consider differing bit arrangements to be equal in value when compared, as long as the net value ultimately appears to be the same?

I'm working on some custom compression algorithms, and it'd be very useful to know if there are multiple ways to represent the same value (for purposes of enhancing compression).


Solution

  • The usual binary IEEE 754 floating-point types do not have the kind of redundancy you are referring to. Numbers are always normalized so that the significand is between 1.0 and 2.0 (or between 1.0 and 10.0 in binary). They do have stuff like positive zero and negative zero, and many NaN that have different internal representations.

    However, the newer decimal IEEE 754 floating-point types do have this redundancy: A number like 3.14 can be represented as 314 with exponent 2; 3140 with exponent 3; 31400 with exponent 4; and so on.