4 ms·
If you have a copy of Knuth's Art of Computer Programming, the section on seminumerical algorithms covers software floating point. Another source is the Handbo
by brandmeyer 8y ago
If you have a copy of Knuth's Art of Computer Programming, the section on seminumerical algorithms covers software floating point.
Another source is the Handbook of Floating Point Arithmetic, which covers both hardware and software methods in detail.
An implementation in source code may be found in libgcc. IIRC their ARM assembly code versions are some of the fastest routines available anywhere for software floating point emulation. While they are in assembly, ARM assembly is fairly intelligible.
Finally, you can probably come up with 90% or more of the correct solutions yourself if you start with the definition of a floating-point number as (-1)^s * 1.m * 2^(e - bias) and grind through the algebra with the bias as a constant. The theorems that prove the minimum number and nature of the guard bits to get correct rounding are another matter, but you can start off by computing the equivalent infinite-precision terms and then rounding.