up previous next
convert rational number to a float string
FloatStr(X:RAT):STRING
FloatStr(X:RAT, Prec:INT):STRING
|
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.
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)
-------------------------------
|