Skip to main content
Previous sectionNext section

PRECISION

Specifies the maximum number of decimal digits when transforming a floating point number.

Synopsis

PRECISION int

Arguments

int An integer specifying the maximum number of decimal digits.

Description

The PRECISION statement specifies the maximum number of decimal digits to display when converting a floating point number. It rounds the decimal portion to the number of decimal digits specified in int. The default number of decimal digits is 4.

PRECISION does not add trailing zeros to numbers with fewer decimal digits than specified.

If int is 0, the null string, or a non-numeric string, PRECISION rounds all decimal digits to the nearest integer value.

Examples

The following example illustrates use of the PRECISION statement to provide a precision value to the FIX function:

mynum=123.987654321
PRINT FIX(mynum)
   ! returns 123.9877 
   ! (rounds to the default precision of 4)
PRECISION 2
PRINT FIX(mynum)
   ! returns 123.99
   ! (rounds to a precision of 2)
Copy code to clipboard

See Also