Rules and definitions

Throughout this document, the word precision is used to mean the number of fractional digits represented in a number. That is, the number of digits to the right of the decimal point.

The phrase significant digits is used to indicate how many digits used to represent a number are valid. This includes both integer (to the left of the decimal point) and fractional (to the right of the decimal point) digits.

Implicit precision is one of the operating modes of the AccuMath utility package. In this mode, the number of fractional digits of the operands supplied to an operation imply the precision that is to be used by the operation. The precision of the operand with the greatest precision is used as the precision for the operation.

When using the implicit precision mode, operands can be set to any precision using the "set precision" function. After these are set, operations using this operand will return results with the same (or greater if another operand had a greater precision) precision. When using this mode, operations like divide (and functions like SIN), do not require the precision to be explicitly specified.

The "set precision" function is used to increase or decrease the precision of an operand. When the precision is increased, trailing zeros are added after the last fractional digit of the number. When the precision is decreased, the number is rounded to the required precision.

Explicit precision is the other operating mode of the AccuMath utility package. In this mode, the precision of the operation might need to be explicitly specified. If the precision is not explicitly specified, a default precision can be used. The default precision is global, and the standard default is 14 digits. The default can be modified by using menu option 5 from the AccuMath menu.

When using the explicit precision mode, all operations and functions accept an optional explicit precision. If the explicit precision is omitted, then either the default precision (divide, SIN, COS, TAN, LN, EXP, PWR, SQRT), or the actual precision resulting from the operation (add, subtract, multiply) will be used. If the explicit precision is specified, the result of the operation or function will be rounded to the specified precision.

The "set precision" function can be used to decrease the precision of an operand, rounding the number to the specified precision.

To avoid inaccurate results and avoid confusion, it is recommended that either the implicit precision or explicit precision mode be used, but not both.

Since all of the arithmetic operations and functions are performed in decimal on strings of decimal digits, there is no formal limit on the number of significant digits that can be used. Likewise, there is no formal limit on the precision to which a number can be represented. However, there is an actual limit, determined by system configuration, which limits the size of the strings that can be manipulated and stored in a BASIC program. Generally, a maximum string length of 32000 digits is considered to be the limit.

Although there is no formal limit on significant digits, since operations are performed in decimal, as operands increase in length, the time required to execute operations and functions increases as well. Operands containing several hundred or thousands of digits may require considerable execution time, especially when using the SIN, COS, TAN, LN, PWR, EXP and SQRT functions.

Note that only the primitive operations add, subtract, multiply, divide and compare are implemented using Assembler subroutines. All other functions are implemented in BASIC as subroutines which call the Assembler subroutines many times.

AccuMath can be used in a BASIC program in any of three ways:
  1. The AccuMath BASIC subroutines may be CALLed to perform the required arithmetic operations. The subroutines are available in both implicit precision and explicit precision versions.
  2. The AccuMath Assembler subroutines may be called by using the BASIC OCONV() function. The definitions for the user-exits are contained in an item that may be included (INCLUDE) in a BASIC program.
  3. AccuMath includes a pre-compiler that can be used to compile programs using string arithmetic functions: SADD(), SSUB(), SMUL(), SDIV() and SCMP(). These functions are compatible with Ultimate's string arithmetic functions, and the pre-compiler allows BASIC source code compatibility with Ultimate.

When using AccuMath within a BASIC program, certain problems arise when combining data derived using the AccuMath subroutines with other numeric data in the program. BASIC will not recognize long strings of digits as numeric (when the binary value of the decimal number exceeds the limits for a numeric BASIC variable). Also, strings of digits with more fractional digits than specified in the PRECISION statement are not recognized as numeric. To minimize this problem, use the AccuMath "set precision" function to set the precision of the data to a BASIC compatible precision before using the data in standard BASIC calculations or storing the data in a file.

Also, large values derived using the AccuMath subroutines, and stored in files, may not be usable by the ACCESS/ENGLISH/RECALL function processor.