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

6.4 Decimal Arithmetic

RWDecimal classes are primarily useful for their ability to represent and perform exact calculations with decimal numbers, including fractions. In this role, they are distinct from the built-in floating point classes that silently and pervasively round numbers to approximations. For addition, subtraction, and multiplication, RWDecimal classes calculate the result exactly, and if the result cannot be represented within the limitations of the RWDecimal<T> an error handler is called.

Because division often results in a value that cannot be expressed exactly as a decimal fraction, division will frequently round results. For most purposes where performance is important, it is better to express division as multiplication (for example, a * 0.25 rather than a /4). If a program uses only the three exact arithmetic operators, it will produce exact results for exact inputs.



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.