The numeric instruction alters values which control the interpretation of numeric computations.
The associated control settings are saved and restored when subroutines and functions are invoked.
This instruction has the following syntax alternatives:
numeric DIGITS [ digitsExpression ]
numeric SCIENTIFIC numeric ENGINEERING numeric FORM [ VALUE ] formValueExpression numeric FUZZ [ fuzzExpression ] |
The numeric digits setting identifies the number of significant digits that are produced by numeric computations. The number of digits is set to the value of the digitsExpression. When the digitsExpression is absent, the number of digits is set to the default setting -- 9 digits. The value of the digitsExpression must be a positive whole number which exceeds the current numeric fuzz setting.
Addition and subtraction perform computations with one additional significant digit, and then the result is rounded to the numeric digits setting. Multiplication produces an internal result that has a length that is less than or equal to the sum of the length of the multiplier and multiplicand combined. This internal value is subsequently rounded to the numeric digits setting. Division is performed in a manner similar to long division that is taught in school. An internal result is produced that has a length that is less than or equal to the numeric digits setting plus 1. As in multiplication, this internal value is subsequently rounded to the numeric digits setting. Unlike multiplication, insignificant trailing zeroes are discarded.
The digits built-in function returns the current setting of the numeric digits value.
Warning: you should not set the number of digits to a small value, or surprising effects may ensue. For example, counted loops may conclude earlier than you would otherwise expect.
Warning: the numeric digits setting affects the validation of whole numbers in various contexts. When the number of digits within a whole number exceeds the numeric digits setting, exponential notation is necessary, and the number could be rounded. Consequently, such large numbers are not considered to be a whole number.
Here is an example of a large numeric digits setting. When 1 is divided by 243 the result is an interesting repeating sequence.
numeric digits 40 say 1 / 243Shows: 0.004115226337448559670781893004115226337449 |
The numeric form setting identifies the presentation format of numbers that require exponential notation. The setting can be either 'SCIENTIFIC' or 'ENGINEERING', or the value of formValueExpression. The default exponential form is 'SCIENTIFIC'.
The form built-in function returns the current setting of the numeric form value.
Hint: the format built-in function is useful for controlling the display of numeric values. The format built-in function is particularly helpful within reports that require values to be presented in uniform columns.
When the form setting is scientific, numbers which require exponential notation will have one leading non-zero digit; such as, 1.2345E+43.
When the form setting is engineering, numbers which require exponential notation will have powers of ten which are multiples of three; such as, 12.345E+42.
The numeric form setting can alternatively be set to the value of formValueExpression. Of course, this value should be either 'SCIENTIFIC' or 'ENGINEERING'.
The value keyword can be omitted if formValueExpression does not begin with a symbol or literal string -- i.e. it could start with a parenthesis.
The numeric fuzz setting identifies the number of digits of accuracy that are IGNORED during numeric comparisons. The fuzziness is set to the value of the fuzzExpression. When the fuzzExpression is absent, the fuzziness is set to the default setting -- 0 digits. The value of the fuzzExpression must be 0, or a positive whole number which is less than the current numeric digits setting.
The fuzz built-in function returns the current setting of the numeric fuzz value.
Note: the fuzz setting is rarely altered. It is useful for performing fuzzy logic computations. Normal computations should use a fuzz setting of 0.