up previous next
DecimalStr

convert rational number to decimal string

Syntax
DecimalStr(X:RAT):STRING
DecimalStr(X:RAT, NumDigits:INT):STRING

Description
This function computes a decimal approximation with NumDigits decimal digits of a rational number (default value is 3) and converts it into a string for printing. If the returned string presents less than NumDigits decimal digits, then the string represents the exact value of the input.

Example
/**/  DecimalStr(1/3);
0.333

/**/  DecimalStr(1/3, 60);
0.333333333333333333333333333333333333333333333333333333333333

/**/  DecimalStr(121/10);
12.1

See Also