Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double - IEEE 754 alternatives

Tags:

c++

ieee-754

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?

like image 674
nf313743 Avatar asked Feb 23 '12 17:02

nf313743


People also ask

Is IEEE 754 still used?

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.

What are the 2 IEEE standards for floating-point number?

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.

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

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.


4 Answers

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.

like image 33
tpg2114 Avatar answered Oct 25 '22 09:10

tpg2114


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.

like image 191
Jerry Coffin Avatar answered Oct 25 '22 10:10

Jerry Coffin


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

like image 2
Anand Avatar answered Oct 25 '22 09:10

Anand


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.

like image 1
gbulmer Avatar answered Oct 25 '22 08:10

gbulmer