This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

The Pentium Non-Bug
• David McClain
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 1999-09-06 (08:25) From: David McClain Subject: The Pentium Non-Bug
```In light of my recent trip around the mulberry bush, I thought I would post
a preamble from some of my code for everyone's sake.

- DM

(* ------------------------------------------------------------ *)
(* Considerable care has been taken to be IEEE correct *)
(* in the face of distinct (+0.0) and (-0.0).          *)

(* The rules of the game are:                                        *)

(*    Addition       => commutative           a + b = b + a          *)
(*    Subtraction    => anticommutative       a - b = -(b - a)       *)
(*    Multiplication => commutative           a * b = b * a          *)
(*    Division       => inverse-commutative   a / b = 1.0 / (b / a)  *)

(*      x + (-0.0) = x   but  x + (+0.0) != x                        *)

(*    Identity under subtraction:                                    *)
(*      x - (+0.0) = x   but  x - (-0.0) != x                        *)

(*    Negation by subtraction:                                       *)
(*      (-0.0) - x = neg x (= FCHS x) but  (+0.0) - x != neg x       *)

(*    Equivalence of subtraction by addition of negative:            *)
(*      a - b = a + neg b                                            *)

(*    Distribution of negation:                                      *)
(*      a - b = -(b - a) = -b - (-a) = -b + a                        *)
(*        ;; remember that addition is commutative                   *)

(*    Complex conjugation by negation:                               *)
(*      conj(re,im) = (re, -im) != (re, 0 - im)                      *)

(* Since the constant 0.0 generally denotes (+0.0) and since it is   *)
(* generally difficult to determine the sign of a given              *)
(* zero constant value, one simply cannot assume that:               *)
(*     0.0 + x = x                                                   *)
(*     x - 0.0 = x                                                   *)
(*     0.0 - x = neg x                                               *)
(* Rather, one must carry out what appears to be a null operation,   *)
(* and be certain to negate when appropriate, instead of subtracting *)
(* from zero.                                                        *)

```