Each integer class has a limit on the length of the numbers it can represent. The length of a number is defined as the number of digits before plus the number of digits after the decimal place. Leading zeros are not counted, but trailing zeros are.
For two numbers numberN and numberM, which are n and m digits long respectively, the maximum length in digits of the result of an arithmetic operation is shown in Table 11.
Operation | Resulting number of digits |
Addition |
Max(n,m)+1 |
Subtraction |
Max(n,m)+1 |
Multiplication |
n + m |
Division |
As many digits as required for an exact result. |
Of the three exact operators, multiplication has the greatest potential for overflow since, for example, the multiplication of two ten digit numbers results in a twenty digit number which will overflow an RWDecimal<RWMP2Int> (18 digits). Division can only cause an overflow if the absolute value of the divisor is less than 1. For example:
100000000000000000 / 0.00000000000000001 = 10000000000000000000000000000000000
This results in an overflow because the result has too many digits before the decimal place.
©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.