up previous next
FloatApprox

approx. of rational number of the form M*2^E

Syntax
FloatApprox(X: INT|RAT|RINGELEM, PrecBits: INT): RAT

Description
This function computes an approximation of the form M*2^E to a rational number X where the mantissa satisfies 2^(B-1) <= |M| < 2^B-1 where B is the specified bit precision. It gives 0 when applied to 0.

The updated version of this function is not backward compatible with the old one; you must replace the 2nd arg by the number of bits you want in the mantissa (see FloorLog2, FloorLog10, FloorLogBase ). The old fn is obsolescent and is now called FloatApprox10 .

Example
/**/  FloatApprox(1/3, 10);
683/2048

/**/  FloatApprox(1/3, 20);
699051/2097152

/**/  FloatApprox(123456789,8);
123207680

See Also