CoCoA:FloatApprox

From ApCoCoAWiki

FloatApprox

approx. of rational number of the form <formula>M*10^E</formula>

Description

This function computes an approximation of the form <formula>M*10^E</formula> 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 <ttref>MantissaAndExponent</ttref>.

Example

  FloatApprox(1/3, 10^(-2));
333/1000
-------------------------------
  FloatApprox(1000000/3, 10^(-2));
333000
-------------------------------
  FloatApprox(1/3, 10^(-9));
3333333333/10000000000
-------------------------------

Syntax

FloatApprox(X:RAT, RelErr:RAT):RAT

DecimalStr

FloatStr

MantissaAndExponent

   <type>rat</type>