CoCoA:FloatStr
From ApCoCoAWiki
FloatStr
convert rational number to a float string
Description
These two functions convert a rational number X into a (decimal)
floating point string. The optional second argument Prec says how many
decimal digits to include in the mantissa; the default value is 10. Note that an exponent is always included; the only exception being the number zero which is converted to the string 0.
Example
FloatStr(2/3); -- last printed digit is rounded 6.666666667*10^(-1) ------------------------------- FloatStr(7^510); -- no arbitrary limit on exponent range 1.000000938*10^431 ------------------------------- FloatStr(1/81, 50); -- precision of mantissa specified by user 1.2345679012345679012345679012345679012345679012346*10^(-2) ------------------------------- FloatStr(1/2); -- trailing zeroes are not suppressed 5.000000000*10^(-1) -------------------------------
Syntax
FloatStr(X:RAT):STRING FloatStr(X:RAT, Prec:INT):STRING
<type>rat</type> <type>string</type>