6
votes

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?

4
I think all of the exceptions are going to be very old. I used a Control Data Cyber that had 60-bit floating point for example.Mark Ransom
According to the repository of all knowledge: some IBM and Cray mainframes, and anything from before the early 80s, use non-IEEE formats.Mike Seymour
Anything that conforms to the C++ standard will do.Alexey Frunze
you can also disable ieee754 with the compiler switch -ffast-math (at least for gcc/clang, mvc has a similar option).Florian
@krynr: That will disable IEEE754 evaluation rules, but you will still have IEEE754 format doubles.MSalters

4 Answers

6
votes

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.

4
votes

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.

2
votes

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

0
votes

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 as float

I believe other CPUs have similar implementations, but I couldn't find them.