floating-pointstandardsoperationsieee

Floating point IEEE guarantees


I would like to know, for the following cases, if the IEEE standard guarantees every possible case (excluding NaN and infinities) using any cpu adhering to the standard:

(# means all operations: + - * /)


Solution

    1. Commutativity: + and * are guaranteed unless either argument is NaN. - and / are not commutative and division by 0.0 gives you +Inf, -Inf, or NaN according to the numerator. Here I'm not giving any consideration to signed zeros.

    2. Associativity. Absolutely not. The addition of two small numbers followed by a large number is a counter-example.

    3. x - x is 0 unless x is NaN, +Inf, or -Inf in which case it is NaN.

    4. x * 0 is 0 unless x is NaN, +Inf, or -Inf in which case it is NaN.

    5. x * 1 is x unless x is NaN in which case it is NaN.

    6. x / x is 1 unless x is 0.0, +Inf, -Inf, or NaN in which case it is NaN.

    Note the subtle difference of (5).