Loading...
 

CX_NUMERIC::SetPrecision

CX_NUMERIC::SetPrecision

Description:

With this function, the number of decimal places can be changed. For a newly created number, this is set to "2" by default. The number can vary between 0 and 8. Unauthorised values do not change the current setting.

The set precision determines the behaviour of import (put) and export(string). Setting the precision does not change the current number.

Code example:

// This example assumes a German locale with ',' as decimal separator to work
Var(num)                       
1.12345 -> num             // Initialize number to 5 decimal places
num String                 // "1,12345"
2 num Call(SetPrecision)   // this will only change display of the number
num String                 // "1,12"
5 num Call(SetPrecision)   // restoring old precision will display original number again
num String                 // "1,12345"

2 num Call(SetPrecision)   // Set precision for import
"1,12345" num Put          // import with 2 decimal places
num String                 // "1,12"
5 num Call(SetPrecision)   // this won't change the number, which has been imported with only 2 decimal places
num String                 // "1,12000"

Stack
Stack Position Object type Brief description
Stack(In) Top CX_NUMERIC, CX_PERCENT or CX_VALUE the number
Top 1 INTEGER the number of desired decimal places
Stack(Out) Top - -

Function call: Call(SetPrecision)