up previous next

DecimalStr

Syntax

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

Summary

convert rational number to decimal 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