Command SET DECIMALS Foundation

Defines the number of decimal places used in the display of numbers.

Syntax
SET DECIMALS TO [<nDecimals>]
Scope
thread-local
Parameters
<nDecimals>
<nDecimals> is a positive integer specifying the number of decimal places in the display of numbers. The default value is 2. When SET DECIMALS TO is called without argument, the value 0 is used for <nDecimals>.
Description

The command SET DECIMALS defines the number of decimal places used in the display of numeric values. The value set using SET DECIMALS is activated by the command SET FIXED ON. As long as SET FIXED is set to OFF, SET DECIMALS determines the minimum number of decimal places for the display of results of numeric operations and functions.

SET DECIMALS and SET FIXED only affect the display of numeric values and not mathematical accuracy.

Examples
SET DECIMALS
// The example illustrates the effect of SET DECIMALS in 
// connection with SET FIXED. 

PROCEDURE Main 
   LOCAL n := Sqrt(2)    // square root of two has an infinite 
                         // number of decimal places 

   SET DECIMALS TO 4 
   SET FIXED ON 

   ? n                   // result:          1.4142 
   ? Str(n,26,15)        // result:          1.414213562373095 
   ? 1/3                 // result:          0.3333 
   ? Str(1/3,26,15)      // result:          0.333333333333333 

   SET FIXED OFF 
   ? 1/3                 // result:          0.33 
   ? n                   // result:          1.41 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.