Function core::num::dec2flt::algorithm::bellerophon
[−]
[src]
pub fn bellerophon<T: RawFloat>(f: &Big, e: i16) -> T
dec2flt
): internal routines only exposed for testing
Algorithm Bellerophon is trivial code justified by non-trivial numeric analysis.
It rounds f
to a float with 64 bit significand and multiplies it by the best approximation
of 10^e
(in the same floating point format). This is often enough to get the correct result.
However, when the result is close to halfway between two adjecent (ordinary) floats, the
compound rounding error from multiplying two approximation means the result may be off by a
few bits. When this happens, the iterative Algorithm R fixes things up.
The hand-wavy "close to halfway" is made precise by the numeric analysis in the paper. In the words of Clinger:
Slop, expressed in units of the least significant bit, is an inclusive bound for the error accumulated during the floating point calculation of the approximation to f * 10e. (Slop is not a bound for the true error, but bounds the difference between the approximation z and the best possible approximation that uses p bits of significand.)