SET PRECISION example
In dBASE Plus the product now supports High Precision Math, this means the total possible PRECISION can be set to 34.
You can temporarily SET PRECISION by using the SET PRECISION TO <nInt>
Or you can change the default SET PRECISION (used at dBASE startup) by going to the menu item ... Properties | Desktop Properties 'Programming' tab and setting 'Precision' under 'Command Output'
NOTE: In order to see the output of the example code below, you should use SET DECIMAL TO ... to match the new precision you've set via SET PRECISION.
In the following code example, starting with the fifth line, it is not clear if the user should be issuing additional calls to SET PRECISION and SET DECIMAL to obtain the results shown:
set decimals to 34 // to see as many digits as possible
set precision to 34 // maximum
? 0.5 // 0.500000000000000 - exact
? 0.375 // 0.375000000000000000 - exact
? 0.4 // 0.400000000000000022 - 16 digits precision
? 1/9 // 0.1111111111111111111111111111111111 - 34 digits precision
? 12345.4 // 12345.400000000000000 - 15 digits precision
? 123456789.4 // 123456789.400000010000000 8 digits precision
In addition, the above output will not work unless SET HIGHPRECISION ON is also issued prior to running the third line of code.
With SET PRECISION = 10
nIDX
= q.rowset.fields['IDx'].value //Where the current field value is 12345678908.00
?nIDX // returns 12345678908.00
nVAl
= 12345678908
?nVAl // returns 1234567E+4
With
SET PRECISION = 11
nVAl = 12345678908
?nVAl // returns 12345678908