up previous next
approx. of rational number of the form
M*10^E
FloatApprox(X:RAT, RelErr:RAT):RAT
|
This function computes an approximation of the form
M*10^E to
a rational number X and to within a maximum specified relative error.
RelErr says indirectly how many decimal digits to include in the
mantissa. Compare with
MantissaAndExponent
.
FloatApprox(1/3, 10^(-2));
333/1000
-------------------------------
FloatApprox(1000000/3, 10^(-2));
333000
-------------------------------
FloatApprox(1/3, 10^(-9));
3333333333/10000000000
-------------------------------
|