Currency Module (only)
Accessing prototypical values (SP-10282)
To access the prototypical values:
RWDecimal<T>::null RWDecimal<T>::missing RWDecimal<T>::NaN RWDecimal<T>::SNaN RWDecimal<T>::infinity |
described in the manual you must use the (undocumented) static member functions:
RWDecimal<T> RWDecimal<T>::nullValue(); RWDecimal<T> RWDecimal<T>::missingValue(); RWDecimal<T> RWDecimal<T>::NaNValue(); RWDecimal<T> RWDecimal<T>::SNaNValue() RWDecimal<T> RWDecimal<T>::infinityValue() |
Floating Point Variables
Gcc compiler optimizations include storing floating point variables in registers. On some machines this results in greater precision than a double should have.
According to the gcc man page:
"For most programs, the excess precision does only good, but a few programs rely on the precise definition of IEEE floating point. Use `-ffloat-store' for such programs." |
This advice applies to portions of the Currency Module code, and we have disabled this particular optimization for non-debug library builds and example-program builds by adding the -ffloat-store option to the compiler command line.
We strongly recommend that you add -ffloat-store to the command line of any non-debug programs built using the Currency Module and the gcc compiler.
Currency Module (only)
Floating Point Variables
Intel C++ compiler optimizations include storing floating point variables in registers. On some machines this results in greater precision than a double should have.
According to the Intel C++ compiler User's Guide:
"The -mp option restricts optimization to maintain declared precision and to ensure that floating-point arithmetic conforms more closely to the ANSI and IEEE standards. For most programs, specifying this option adversely affects performance. If you are not sure whether your application needs this option, try compiling and running your program both with and without it to evaluate the effects on both performance and precision." |
This advice applies to portions of the Currency Module code.
We strongly recommend that you add -mp to the command line of any non-debug programs built using the Currency Module and the Intel C++ compiler.
Inexact exception for results with insignificant trailing zeros
Multiplication where the result contains insignificant trailing zeros may cause an inexact exception to be thrown, even if the result is represented exactly (SP-10262). In the following example, in which the class RWDecimal< RWMultiPrecisionInt<2> > can represent numbers with 18 decimal digits, an inexact exception will be generated:
RWDecimal< RWMultiPrecisionInt<2> > valA = "5282.80977864"; RWDecimal< RWMultiPrecisionInt<2> > valB = "1000000000"; RWDecimal< RWMultiPrecisionInt<2> > valMul = valA*valB; cout << "valA : " << valA << endl; cout << "valB : " << valB << endl; cout << "valMul: " << valMul << endl; |
The program creates the following output:
[MULINEXACT] RWDecimal: inexact result in multiplication valA : 5282.80977864 valB : 1000000000 valMul : 5282809778640.00000 // 18 digit result still exact |
In one sense, the inexact exception is correct, since a certain number of significant digits are lost in the calculation. It just happens that those digits are all zeros.
Some Math Examples Require an Input File
Some of the Math Module's example programs require an input file. These input files are located inside the installdir\examples\math in directory, and are required by examples one, two, and eight.
You can modify these input files to try the examples with different input data.
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.
Provide feedback to Rogue Wave about its documentation.