Search code examples
ieee-754

What does The IEEE-754 mean by "interchange formats"?


The standard says that they support the exchange of floating-point data between implementations. What is meant by 'implementations' here? And how that exchange may occur?


Solution

  • The standard, like many programming standards, specifies a set of rules. Anything that follows those rules is an implementation of the standard. Per the IEEE 754-2008 abstract, “An implementation of a floating-point system conforming to this standard may be realized entirely in software, entirely in hardware, or in any combination of software and hardware.”

    For example, one could, in theory, design a computer processor that natively supports floating-point formats and that has one instruction for each IEEE 754 operation. Or you could write a C compiler that targets a processor which has some floating-point operations, like addition and multiplication, but uses software routines for square root and other operations. Or you could write software that implements all the IEEE 754 operations using purely C integer operations, without any reliance on any specific hardware. Each of these could be an IEEE 754 implementation.

    The floating-point behaviors are specified largely in terms of the mathematical values represented. For arithmetic formats, the standard specifies what numbers are represented, what the results of performing arithmetic operations on them are, and so on. Interchange formats go further than this; for interchange formats, the standard specifies precisely what bit patterns represent which values.

    Because of this, if one IEEE 754 implementation puts a value in a floating-point object and then transmits the bits to another implementation, possibly running on completely different hardware, and that destination implementation restores those bits to a floating-point object of the same interchange format, then the destination object will have the same value and behavior as the original source object. In other words, the interchange formats make data portable.

    This transmission can occur over a network, by storage of the bits onto a disk that is then physically moved to another computer, by printing the bits (or a representation of them, such as hexadecimal) on paper that is then typed in by a human, or other means.

    The standard specifies only the bit pattern in a sequence of bits from most significant to least significant. It does not specify how those bits are grouped into bytes or how those bytes are ordered, so sending and receiving systems must be sure to send and receive the bits in the correct order.