According to the following site: http://en.cppreference.com/w/cpp/language/types
"double - double precision floating point type. Usually IEEE-754 64 bit floating point type".
It says "usually". What other possible formats/standard could C++ double
use? What compiler uses an alternative to the IEEE format? Or architecture?
Unless your planning on supporting your library on fairly exotic CPU architectures, it is safe to assume that for now 99% of CPUs are IEEE 754 compliant.
There are three binary floating-point basic formats (encoded with 32, 64 or 128 bits) and two decimal floating-point basic formats (encoded with 64 or 128 bits). The binary32 and binary64 formats are the single and double formats of IEEE 754-1985 respectively.
IEEE 754 numbers are divided into two based on the above three components: single precision and double precision. Special Values: IEEE has reserved some values that can ambiguity. Zero is a special value denoted with an exponent and mantissa of 0. -0 and +0 are distinct values, though they both are equal.
For a short history lesson, you can check out the Intel Floating Point Case Study.
Intel compilers have an option that is on by default when optimizing that enables a so-called fast-math feature. This makes the math much faster but drops strict compliance with IEEE standards. One can enforce strict standard compliance with the fp-model option.
I believe the CUDA language for NVidia GPU's also has a significantly faster math library if one is willing to give up strict compliance with the IEEE standard. This not only makes the math faster, but it reduces the number of registers used for transcendental functions in particular.
Whether compliance is needed depends on a case-by-case basis. We've experienced problems with the Intel optimizations and have had to turn on the fp-model strict
option to ensure correct results with double precision math.
Vaxen, Crays, and IBM mainframes, to name just a few that are still in reasonably wide use. Most (all?) of those can also do IEEE floating point now, but sometimes only with a special add-on. In other cases (IBM) IEEE arithmetic can carry a significant speed penalty.
As for older machines, most mainframes (Unisys, Control Data, etc.) used unique floating point formats, most of which weren't even much like IEEE, not to mention actually conforming.
Seems most computers today use IEEE-754. But alternatives seems to have been available before. Formats like excess 128 and packed BCD have been used before (http://aplawrence.com/Basics/floatingpoint.html). The wikipedia entry too has a few listed http://en.wikipedia.org/wiki/Floating_point
It is probably worth adding, in answer to "What other possible formats/standard could C++ double use?", that gcc for Atmel AVR (which are 8 bit data CPU's, used in some Arduinos) does not implement double
as 64 bits.
See the GCC wiki, avr-gcc page and specifically the 'double' subsection of 'Deviations from the Standard' where it says
double
is only 32 bits wide and implemented in the same way asfloat
I believe other CPUs have similar implementations, but I couldn't find them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With