Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Currency Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

8.2 Overflow Conditions

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 8.

Table 8: Digits resulting from arithmetic operations 

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:

This results in an overflow because the result has too many digits before the decimal place.



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.