Reference: ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
IEEE 754; the floating point standard developed by the IEEE and supported by virtually all microprocessors today (other than those which don't do FP at all). JavaLanguage requires IEEE 754 semantics for its "float" and "double" types (though newer versions of JavaLanguage have relaxed this requirement somewhat at the behest of the NumericalAnalysis community).
Despite its ubiquity; IEEE 754 is the frequent target of barbs from numerical analysts who find various reasons to despise its semantics.
IEEE 754 has the following properties:
- Two datatypes are specified--a "single precision" (32-bit) float, and a "double precision" (64-bit) float. Correspond to float and double, respectively, in JavaLanguage and most C/C++ implementations.
- Uses a binary (rather than BinaryCodedDecimal) representation; making it impossible to represent arbitrary terminating decimal fractions exactly. Only fractional powers-of-two may be represented accurately. (See FloatingPointCurrency for discussion of this feature).
- Features distinct values for "positive zero" and "negative zero"; but no "exactly zero". This is the source of endless amusing debate. No other number has such dual treatment.
- Uses "one's complement" representation, sort of.
- Has both "normalized" and "denormalized" numbers; Normalized numbers (with the sign bit clear) represent the range [2^k, 2*2^k) for the exponent k (note the range is open on the top and closed on the bottom). Denormalized numbers represent the range [0, 2^k). Zero is a denormalized number (positive and negative zero).
- Have separate forms for "positive infinity" and "negative infinity"; division of a non-zero value by positive zero gives you the infinity corresponding to the sign of the dividend. Division by NegativeZero? gives you the opposite infinity.
- Has two other forms, NotaNumber and SignallingNan. Computing 0/0, infinity - infinity, or any number of ill-behaved operations gives you one of these. (Which one is user selectable by a register, typically). Computations involving NotaNumber return NotaNumber; computations involving SignallingNan result in a processor exception.
- Also has different (and user-settable) rounding modes, to specify what happens when compuations result in loss of precision.
- Has the interesting and useful property that two's complement comparisons of the underlying bit pattern of any two IEEE 754 numbers will have the same result as comparing the numbers that are represented (excluding comparisons with NotaNumber or SignallingNan). Is +0 vs. -0 a specific exception to this, or is there a more general set of exceptions? --AdamBerger AnswerMe
CategoryCodingIssues