Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is IEEE-754 Floating Point not exchangable between platforms?

It has been asserted that (even accounting for byte endian-ness) IEEE754 floating point is not guaranteed to be exchangeable between platforms.

So:

  • Why, theoretically, is IEEE floating point not exchangeable between platforms?
  • Are any of these concerns valid for modern hardware platforms (e.g. i686, x64, arm)?

If the concerns are valid, can you please demonstrate an example where this is the case (C or C++ is preferred)?


Motivation: Several GPS manufacturers exchange their binary formats for (e.g.) latitude, longitude and raw data in "IEEE-754 compliant floating point values". So, I don't have control to choose a text format or other "portable" format. Hence, my question has to when the differences may or may not occur.

like image 395
Damien Avatar asked Oct 14 '13 00:10

Damien


People also ask

What are the key characteristics of the IEEE 754 notation for representing floating-point numbers?

The IEEE 754 standard specifies two precisions for floating-point numbers. Single precision numbers have 32 bits − 1 for the sign, 8 for the exponent, and 23 for the significand. The significand also includes an implied 1 to the left of its radix point.

How does the result of invalid operation represent in IEEE 754?

Not A Number (NAN) – The value NAN is used to represent a value that is an error. This is represented when exponent field is all ones with a zero sign bit or a mantissa that it not 1 followed by zeros. This is a special value that might be used to denote a variable that doesn't yet hold a value.

Why is the IEEE 754 standard important?

The standard specifies optional extended and extendable precision formats, which provide greater precision than the basic formats. An extended precision format extends a basic format by using more precision and more exponent range.

Which are the correct IEEE 754 single and double precision formats?

In the IEEE 754-2008 standard, the 64-bit base-2 format is officially referred to as binary64; it was called double in IEEE 754-1985. IEEE 754 specifies additional floating-point formats, including 32-bit base-2 single precision and, more recently, base-10 representations.


1 Answers

IEEE 754 clause 3.4 specifies binary interchange format encodings. Given a floating-point format (below), the interchange format puts the sign bit in the most significant bit, biased exponent bits in the next most significant bits, and the significand encoding in the least significant bits. A mapping from bits to bytes is not specified, so a system could use little-endian, big-endian, or other ordering.

Clause 3.6 specifies format parameters for various format widths, including 64-bit binary, for which there is one sign bit, 11 exponent field bits, and 52 significand field bits. This clause also specifies the exponent bias.

Clauses 3.3 and 3.4 specify the data represented by this format.

So, to interchange IEEE-754 floating-point data, it seems systems need only to agree on two things: which format to use (e.g., 64-bit binary) and how to get the bits back and forth (e.g., how to map bits to bytes for writing to a file or a network message).

like image 65
Eric Postpischil Avatar answered Oct 03 '22 00:10

Eric Postpischil