SourcePro C++ 12.0 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Exact representation of a decimal fraction with a fixed number of digits after the decimal point, with automatic rounding to ensure correct number of decimal places. More...
#include <rw/currency/fixeddec.h>
Public Member Functions | |
RWFixedDecimal () | |
RWFixedDecimal (const RWFixedDecimal< M > &d) | |
operator RWDecimalPortable () const | |
RWFixedDecimal (const RWDecimal< M > &d) | |
RWFixedDecimal (int i) | |
RWFixedDecimal (long int i) | |
RWFixedDecimal (int x, int e) | |
RWFixedDecimal (long int x, int e) | |
RWFixedDecimal (const char *s) | |
RWFixedDecimal< M > | operator- () const |
RWFixedDecimal< M > | operator+ () const |
RWFixedDecimal< M > & | operator= (const RWFixedDecimal< M > &x) |
RWFixedDecimal< M > & | operator+= (const RWFixedDecimal< M > &a) |
RWFixedDecimal< M > & | operator-= (const RWFixedDecimal< M > &a) |
RWFixedDecimal< M > & | operator*= (const RWFixedDecimal< M > &a) |
RWFixedDecimal< M > & | operator/= (const RWFixedDecimal< M > &a) |
void | saveOn (RWvostream &s) const |
void | restoreFrom (RWvistream &s) |
void | saveOn (RWFile &f) const |
void | restoreFrom (RWFile &f) |
int | isNumber () const |
int | decimalPlaces () const |
Static Public Member Functions | |
static void | setInexactHandler (void(*eh)(const RWDecimalInexactErr< M > &)) |
static void | setOverflowHandler (void(*eh)(const RWDecimalOverflowErr< M > &)) |
static int | maxDigits () |
static RWFixedDecimal< M > | maxValue () |
static RWFixedDecimal< M > | minValue () |
static RWFixedDecimal< M > | from (double x) |
static RWFixedDecimal< M > | from (long double x) |
static RWFixedDecimal< M > | pow (const RWFixedDecimal< M > &x, int e) |
static RWFixedDecimal< M > | round (const RWFixedDecimal< M > &x, int n, RWDecimalBase::RoundingMethod rm) |
Static Public Attributes | |
static const RWFixedDecimal< M > | null |
static const RWFixedDecimal< M > | missing |
static const RWFixedDecimal< M > | NaN |
static const RWFixedDecimal< M > | SNaN |
static const RWFixedDecimal< M > | infinity |
Related Functions | |
(Note that these are not member functions.) | |
template<class M > | |
RWFixedDecimal< M > | operator+ (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator+ (const RWFixedDecimal< M > &a, const RWDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator+ (const RWDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator+ (const RWFixedDecimal< M > &a, int b) |
template<class M > | |
RWFixedDecimal< M > | operator+ (const RWFixedDecimal< M > &a, long b) |
template<class M > | |
RWFixedDecimal< M > | operator+ (int a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator+ (long a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator- (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator- (const RWFixedDecimal< M > &a, const RWDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator- (const RWDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator- (const RWFixedDecimal< M > &a, int b) |
template<class M > | |
RWFixedDecimal< M > | operator- (const RWFixedDecimal< M > &a, long b) |
template<class M > | |
RWFixedDecimal< M > | operator- (int a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator- (long a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator* (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator* (const RWFixedDecimal< M > &a, const RWDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator* (const RWDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator* (const RWFixedDecimal< M > &a, double b) |
template<class M > | |
RWFixedDecimal< M > | operator* (double a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator* (const RWFixedDecimal< M > &a, int b) |
template<class M > | |
RWFixedDecimal< M > | operator* (const RWFixedDecimal< M > &a, long b) |
template<class M > | |
RWFixedDecimal< M > | operator* (int a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator* (long a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWFixedDecimal< M > &a, const RWDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWFixedDecimal< M > &a, double b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (double a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWFixedDecimal< M > &a, int b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWFixedDecimal< M > &a, long b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (int a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (long a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWFixedDecimal< M > &a, const char *b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const char *a, const RWFixedDecimal< M > &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWFixedDecimal< M > &a, const RWDecimalPortable &b) |
template<class M > | |
RWFixedDecimal< M > | operator/ (const RWDecimalPortable &a, const RWFixedDecimal< M > &b) |
template<class M > | |
bool | operator== (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
bool | operator< (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
bool | operator!= (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
bool | operator> (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
bool | operator<= (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
bool | operator>= (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b) |
template<class M > | |
std::istream & | operator>> (std::istream &strm, RWFixedDecimal< M > &x) |
template<class M > | |
std::ostream & | operator<< (std::ostream &strm, const RWFixedDecimal< M > &x) |
template<class M > | |
RWFixedDecimal< M > | abs (const RWFixedDecimal< M > &x) |
template<class M > | |
RWCString | toString (const RWFixedDecimal< M > &d) |
template<class M > | |
long double | toDouble (const RWFixedDecimal< M > &d) |
template<class M > | |
long int | toInt (const RWFixedDecimal< M > &d) |
template<class M > | |
long int | toInt (const RWFixedDecimal< M > &d, RWDecimalBase::RoundingMethod m) |
RWFixedDecimal<T> classes are exact representations of decimal fractions with a fixed number of digits after the decimal point. In most ways, they behave exactly like the corresponding RWDecimal<T> classes. The exception is that rounding automatically occurs to insure the correct number of decimal places.
RWFixedDecimal<T> is templatized. Three short type names are provided: RWFixedDecimal<RWMP1Int>, RWFixedDecimal<RWMP2Int>, and RWFixedDecimal<RWMP3Int>. Each type provides a different amount of precision, as described below in the Limits section. The trade-off is simple: the more precision, the slower the class.
You may also write your own RWFixedDecimal<T> class. Throughout this section, when we refer to the RWFixedDecimal<T> class, you can assume that it applies to any of the three provided classes, or to one you have defined.
#include <rw/currency/fixeddec.h> // for RWFixedDecimal<T> #include <rw/currency/mp2int.h> // For RWMP2Int RWFixedDecimal<RWMP2Int> dollarAccount(0,2) = "0.01"; // initialize to zero then set to 2 decimal places
The following header files are available for backward compatibility:
#include <rw/fixdec52.h> // RWFixedDecimal52 #include <rw/fixdec64.h> // RWFixedDecimal64 #include <rw/fixdec96.h> // RWFixedDecimal96
#include <iostream> #include <rw/currency/fixeddec.h> #include <rw/currency/mp2int.h> int main() { RWFixedDecimal<RWMP2Int> penny = "0.01"; RWFixedDecimal<RWMP2Int> bank = 0; for(int i=100; i--;) bank+=penny; // deposit 100 pennies bank -= 1; // withdraw a buck std::cout << (bank==0 ? "broke!" : "whew! still solvent") << std::endl; return 0; }
Class RWFixedDecimal<T> provides three static member functions that can be used to define the limits on an RWFixedDecimal<T> object. These functions return the precision, maximum value, and minimum value:
int RWFixedDecimal<T>::maxDigits(); // precision RWFixedDecimal<T> RWFixedDecimal<T>::maxValue(); // maximum value RWFixedDecimal<T> RWFixedDecimal<T>::minValue(); // minimum value
Note that the precision returned by maxDigits() does not usually represent the number of digits in the largest possible RWFixedDecimal<T> object. Rather, it indicates the maximum number of digits supported by that object without returning an overflow error. For example the number shown in Table 6 as the maximum value for RWFixedDecimal<RWMP2Int> has 19 digits. Notice, however, that any number larger than the 19-digit number shown will cause an overflow error because it exceeds the maximum value. Therefore, RWFixedDecimal<RWMP2Int>::maxDigits() returns 18, because that is the number of digits that will always be supported without an overflow error.
The following code snippets demonstrate when an overflow condition caused by exceeding a maximum value will occur:
// Set max to maximum value: RWFixedDecimal<RWMP1Int>max = RWFixedDecimal<RWMP1Int>::maxValue(); // Add 1 to max to generate an overflow error: RWFixedDecimal<RWMP1Int>tooBig = max + RWFixedDecimal<RWMP1Int>(1); // Set min to minimum value: RWFixedDecimal<RWMP1Int>min = RWFixedDecimal<RWMP1Int>::minValue(); // Subtract 1 from min to generate an overflow error: RWFixedDecimal<RWMP1Int>tooSmall = min-RWFixedDecimal<RWMP1Int>(1) ;
Table 6 indicates the minimum and maximum values for RWFixedDecimal<T> when T
is replaced by one of the provided multiprecision integer types:
Class | Minimum value | Max Digits |
---|---|---|
Maximum value | ||
RWDecimal<RWMP3Int> | -39614081257132168796771975167 | 28 |
39614081257132168796771975167 | ||
RWDecimal<RWMP2Int> | -9223372036854775807 | 18 |
9223372036854775807 | ||
RWDecimal<RWMP1Int> | -9007199254740991 | 15 |
9007199254740991 |
As well as representing a decimal fraction, an RWFixedDecimal<T> can also represent one of several non-numeric values. This concept has several uses, including, for example, representing a null entry from a database or indicating a missing value in data that is to be subjected to a statistical analysis. Currency Module supports three sorts of non-numeric values: null, missing, and NaN (Not a Number).
The result of performing arithmetic with a missing or an NaN is itself a missing or an NaN. An arithmetic operation in which one operand is a null returns either a valid number or an NaN (details are given below). Thus, missing values and NaN values propagate while null values do not.
The special static variables RWFixedDecimal::missing, RWFixedDecimal::null, and RWFixedDecimal::NaN are the prototype missing and null values; to set up a non-numeric RWFixedDecimal<T> use these static variables along with either the copy constructor or the assignment operator. To test for a non-numeric value, use these values along with an equality operator. You can use the member function isNumber() to test if an RWFixedDecimal<T> has a numeric value.
For the most part, arithmetic between RWFixedDecimal<T> objects is defined very simply: you get back an exact representation of the result of the operation. There are several special cases, however:
RWFixedDecimal< M >::RWFixedDecimal | ( | ) | [inline] |
Constructs an RWFixedDecimal<T> with a value of null.
RWFixedDecimal< M >::RWFixedDecimal | ( | const RWFixedDecimal< M > & | d | ) | [inline] |
Copy constructor. Constructs an RWFixedDecimal<T> that is a copy of the argument.
RWFixedDecimal< M >::RWFixedDecimal | ( | const RWDecimal< M > & | d | ) | [inline] |
Constructs an RWFixedDecimal<T> that represents the same value as the parameter. The number of decimal places is fixed to be the same as the parameter.
RWFixedDecimal< M >::RWFixedDecimal | ( | int | i | ) | [inline] |
Constructs an RWFixedDecimal<T> with value i. The explicit integer constructors prevent initializations from 0 from being ambiguous. Without the int
constructor, the compiler would not know whether to convert 0 to a const
char*
or a long
int
.
RWFixedDecimal< M >::RWFixedDecimal | ( | long int | i | ) | [inline] |
Constructs an RWFixedDecimal<T> with value i.
RWFixedDecimal< M >::RWFixedDecimal | ( | int | x, | |
int | e | |||
) | [inline] |
Constructs an RWFixedDecimal<T> with value x*10-e
where e
represents the number of digits after the decimal point.
RWFixedDecimal< M >::RWFixedDecimal | ( | long int | x, | |
int | e | |||
) | [inline] |
Constructs an RWFixedDecimal<T> with value x*10-e
where e
represents the number of digits after the decimal point.
RWFixedDecimal< M >::RWFixedDecimal | ( | const char * | s | ) | [inline] |
Constructs an RWDecimal<T> from the null terminated character string s. Since we write numbers using base 10 and the RWDecimal<T> class stores numbers using base 10, the number constructed is an exact representation of the string. If the string cannot be successfully parsed as a number, the RWDecimal<T> is initialized to null. If the number in the string cannot be exactly represented (for example, it has too many significant digits) then the appropriate error handler (either the inexact or overflow handler) is called. The string may contain embedded commas to separate groups of digits and may have a leading dollar sign. Negatives can be indicated with a negative sign or by using parentheses. For more information on exact input grammar allowed, see the discussion of Input Format Grammar in the Currency Module User's Guide.
int RWFixedDecimal< M >::decimalPlaces | ( | ) | const [inline] |
Returns the number of digits to the right of the decimal point.
Reimplemented from RWDecimal< M >.
static RWFixedDecimal<M> RWFixedDecimal< M >::from | ( | long double | double | ) | [inline, static] |
Converts a floating point value to an RWDecimal. Results may be inexact.
Reimplemented from RWDecimal< M >.
static RWFixedDecimal<M> RWFixedDecimal< M >::from | ( | double | ) | [inline, static] |
Converts a floating point value to an RWDecimal. Results may be inexact.
Reimplemented from RWDecimal< M >.
int RWFixedDecimal< M >::isNumber | ( | ) | const [inline] |
Returns true
if self represents a decimal fraction; returns false
if self is not a representation of a number; for example, if self is a null or missing value.
Reimplemented from RWDecimal< M >.
static int RWFixedDecimal< M >::maxDigits | ( | ) | [inline, static] |
Returns the maximum number of digits that an RWDecimal<T> of the indicated type is guaranteed to represent without overflow. In most cases, an RWDecimal<T> can represent some numbers of length actualDigits
, where actualDigits=
maxDigits() + 1
. For example, the maxDigits() value for class RWDecimal<T> is 18, even though the number of digits in the maxValue() for the class is 19.
Reimplemented from RWDecimal< M >.
static RWFixedDecimal<M> RWFixedDecimal< M >::maxValue | ( | ) | [inline, static] |
Returns the maximum value that can be represented by this class. The maximum value +1 will always generate an overflow error.
Reimplemented from RWDecimal< M >.
static RWFixedDecimal<M> RWFixedDecimal< M >::minValue | ( | ) | [inline, static] |
Returns the minimum value that can be represented by this class. The minimum value -1 will always generate an overflow error.
Reimplemented from RWDecimal< M >.
RWFixedDecimal< M >::operator RWDecimalPortable | ( | ) | const [inline] |
Conversion to a portable decimal object. This is most often used implicitly to interface with a facility such as I/O or type conversion.
Reimplemented from RWDecimal< M >.
RWFixedDecimal<M>& RWFixedDecimal< M >::operator*= | ( | const RWFixedDecimal< M > & | a | ) | [inline] |
Performs the operation between self and the argument, and stores the results in self.
RWFixedDecimal<M> RWFixedDecimal< M >::operator+ | ( | ) | const [inline] |
Returns the result of applying the unary operator.
Reimplemented from RWDecimal< M >.
RWFixedDecimal<M>& RWFixedDecimal< M >::operator+= | ( | const RWFixedDecimal< M > & | a | ) | [inline] |
Performs the operation between self and the argument, and stores the results in self.
RWFixedDecimal<M> RWFixedDecimal< M >::operator- | ( | ) | const [inline] |
Returns the result of applying the unary operator.
Reimplemented from RWDecimal< M >.
RWFixedDecimal<M>& RWFixedDecimal< M >::operator-= | ( | const RWFixedDecimal< M > & | a | ) | [inline] |
Performs the operation between self and the argument, and stores the results in self.
RWFixedDecimal<M>& RWFixedDecimal< M >::operator/= | ( | const RWFixedDecimal< M > & | a | ) | [inline] |
Performs the operation between self and the argument, and stores the results in self.
RWFixedDecimal<M>& RWFixedDecimal< M >::operator= | ( | const RWFixedDecimal< M > & | x | ) |
Sets value of self equal to the value of the argument.
static RWFixedDecimal<M> RWFixedDecimal< M >::pow | ( | const RWFixedDecimal< M > & | x, | |
int | e | |||
) | [inline, static] |
Returns x raised to the exponent e. This computation is likely to cause a loss of precision (and a corresponding call to the precision error handler) if e is at all large and x has any decimal places.
void RWFixedDecimal< M >::restoreFrom | ( | RWFile & | ) | [inline] |
Restores value of self from an RWFile. The RWFile class is provided with Rogue Wave's Essential Tools Module class library. This function requires that you link in the Essential Tools Module library.
Reimplemented from RWDecimal< M >.
void RWFixedDecimal< M >::restoreFrom | ( | RWvistream & | ) | [inline] |
Restores value of self from a virtual stream. The virtual stream class is provided with Rogue Wave's Essential Tools Module class library. This function requires that you link in the Essential Tools Module library.
Reimplemented from RWDecimal< M >.
static RWFixedDecimal<M> RWFixedDecimal< M >::round | ( | const RWFixedDecimal< M > & | x, | |
int | n, | |||
RWDecimalBase::RoundingMethod | rm | |||
) | [inline, static] |
Returns x rounded to n decimal places. The method of rounding is controlled by the optional last parameter as follows:
Table 7: Methods of rounding
Method | Description | 1.25 | 1.35 | 1.251 |
PLAIN | Rounds away from zero on a tie | 1.3 | 1.4 | 1.3 |
UP | Always rounds away from zero | 1.3 | 1.4 | 1.3 |
DOWN | Always rounds toward zero | 1.2 | 1.3 | 1.2 |
TRUNCATE | Same as DOWN | 1.2 | 1.3 | 1.2 |
BANKERS | On a tie, round so last digit is even | 1.2 | 1.4 | 1.3 |
The last three columns indicate the result of rounding three example numbers to one decimal place.
void RWFixedDecimal< M >::saveOn | ( | RWFile & | ) | const [inline] |
Stores value of self to an RWFile in binary format. The RWFile class is provided with Rogue Wave's Essential Tools Module class library. This function requires that you link in the Essential Tools Module library.
Reimplemented from RWDecimal< M >.
void RWFixedDecimal< M >::saveOn | ( | RWvostream & | ) | const [inline] |
Stores value of self to a virtual stream. The virtual stream class is provided with Rogue Wave's Essential Tools Module class library. This function requires that you link in the Essential Tools Module library.
Reimplemented from RWDecimal< M >.
static void RWFixedDecimal< M >::setInexactHandler | ( | void(*)(const RWDecimalInexactErr< M > &) | eh | ) | [inline, static] |
Sets the function that is called when an "inexact" error occurs. This type of error most often indicates the use of an arithmetic operation that will cause loss of precision in the result. defaultInexactHandler
, the default error handler, prints an error message, but does not throw an exception.
Reimplemented from RWDecimal< M >.
static void RWFixedDecimal< M >::setOverflowHandler | ( | void(*)(const RWDecimalOverflowErr< M > &) | eh | ) | [inline, static] |
Sets the function that is called when an "overflow" error occurs. This type of error most often indicates the use of an arithmetic operation that will cause a result larger than can be stored. The default error handler, defaultOverflowHandler
, simply throws the error object as a C++ exception.
Reimplemented from RWDecimal< M >.
RWFixedDecimal< M > abs | ( | const RWFixedDecimal< M > & | x | ) | [related] |
Returns the absolute value of x.
bool operator!= | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
The inequality operator returns false
if the two operands are exactly the same, and true
otherwise.
RWFixedDecimal< M > operator* | ( | long | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator* | ( | int | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator* | ( | const RWFixedDecimal< M > & | a, | |
long | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator* | ( | const RWFixedDecimal< M > & | a, | |
int | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator* | ( | double | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator* | ( | const RWFixedDecimal< M > & | a, | |
double | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator* | ( | const RWDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator* | ( | const RWFixedDecimal< M > & | a, | |
const RWDecimal< M > & | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator* | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Multiplication operator.
RWFixedDecimal< M > operator+ | ( | long | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Addition operator
RWFixedDecimal< M > operator+ | ( | int | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Addition operator
RWFixedDecimal< M > operator+ | ( | const RWFixedDecimal< M > & | a, | |
long | b | |||
) | [related] |
Addition operator
RWFixedDecimal< M > operator+ | ( | const RWFixedDecimal< M > & | a, | |
int | b | |||
) | [related] |
Addition operator
RWFixedDecimal< M > operator+ | ( | const RWDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Addition operator
RWFixedDecimal< M > operator+ | ( | const RWFixedDecimal< M > & | a, | |
const RWDecimal< M > & | b | |||
) | [related] |
Addition operator
RWFixedDecimal< M > operator+ | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Addition operator
RWFixedDecimal< M > operator- | ( | long | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Subtraction operator.
RWFixedDecimal< M > operator- | ( | int | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Subtraction operator.
RWFixedDecimal< M > operator- | ( | const RWFixedDecimal< M > & | a, | |
long | b | |||
) | [related] |
Subtraction operator.
RWFixedDecimal< M > operator- | ( | const RWFixedDecimal< M > & | a, | |
int | b | |||
) | [related] |
Subtraction operator.
RWFixedDecimal< M > operator- | ( | const RWDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Subtraction operator.
RWFixedDecimal< M > operator- | ( | const RWFixedDecimal< M > & | a, | |
const RWDecimal< M > & | b | |||
) | [related] |
Subtraction operator.
RWFixedDecimal< M > operator- | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Subtraction operator.
RWFixedDecimal< M > operator/ | ( | const RWDecimalPortable & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const RWFixedDecimal< M > & | a, | |
const RWDecimalPortable & | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const char * | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const RWFixedDecimal< M > & | a, | |
const char * | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | long | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | int | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const RWFixedDecimal< M > & | a, | |
long | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const RWFixedDecimal< M > & | a, | |
int | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | double | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const RWFixedDecimal< M > & | a, | |
double | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const RWDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const RWFixedDecimal< M > & | a, | |
const RWDecimal< M > & | b | |||
) | [related] |
Division Operator
RWFixedDecimal< M > operator/ | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
Division Operator
bool operator< | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
std::ostream & operator<< | ( | std::ostream & | strm, | |
const RWFixedDecimal< M > & | x | |||
) | [related] |
Writes an RWFixedDecimal<T> to an output stream. Output is written in the form -xxx.yyy
where the xxx
and yyy
are integers and only the necessary parts are written. For more elaborate formatting, use an RWDecimalFormat object.
bool operator<= | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
bool operator== | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
The equality operator returns true
if the two operands are exactly the same, and false
otherwise.
bool operator> | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
bool operator>= | ( | const RWFixedDecimal< M > & | a, | |
const RWFixedDecimal< M > & | b | |||
) | [related] |
std::istream & operator>> | ( | std::istream & | strm, | |
RWFixedDecimal< M > & | x | |||
) | [related] |
Reads an RWFixedDecimal<T> from an input stream. The format expected is (-xxx.yyy
) where the xxx
and yyy
are integers (which may begin with zeros) and all the parts -- parentheses, minus sign, xxx
, decimal point, and yyy
-- are optional. Since we write numbers using base 10, and the RWFixedDecimal<T> class stores numbers using base 10, the number constructed is an exact representation of the input.
long double toDouble | ( | const RWFixedDecimal< M > & | d | ) | [related] |
Converts the argument to a double precision value close to its true value.
long int toInt | ( | const RWFixedDecimal< M > & | d, | |
RWDecimalBase::RoundingMethod | m | |||
) | [related] |
Converts the argument to an integer. The method of rounding is controlled by the last parameter, as described in detail in the description of the global function round().
long int toInt | ( | const RWFixedDecimal< M > & | d | ) | [related] |
Converts the argument to an integer. The method of rounding used is RWDecimalBase::PLAIN, as described in detail in the description of the global function round().
RWCString toString | ( | const RWFixedDecimal< M > & | d | ) | [related] |
Converts an RWFixedDecimal<T> to a string. The string has the form xxx.yyy
where the xxx
and yyy
are integers and only the parts necessary are written. For more elaborate formatting, use an RWDecimalFormat object.
const RWFixedDecimal<M> RWFixedDecimal< M >::infinity [static] |
These are the prototype non-numeric values. Use these to set a RWDecimal<T> to a non-numeric value or to test for a specific non-numeric value.
Reimplemented from RWDecimal< M >.
const RWFixedDecimal<M> RWFixedDecimal< M >::missing [static] |
These are the prototype non-numeric values. Use these to set a RWDecimal<T> to a non-numeric value or to test for a specific non-numeric value.
Reimplemented from RWDecimal< M >.
const RWFixedDecimal<M> RWFixedDecimal< M >::NaN [static] |
These are the prototype non-numeric values. Use these to set a RWDecimal<T> to a non-numeric value or to test for a specific non-numeric value.
Reimplemented from RWDecimal< M >.
const RWFixedDecimal<M> RWFixedDecimal< M >::null [static] |
These are the prototype non-numeric values. Use these to set a RWDecimal<T> to a non-numeric value or to test for a specific non-numeric value.
Reimplemented from RWDecimal< M >.
const RWFixedDecimal<M> RWFixedDecimal< M >::SNaN [static] |
These are the prototype non-numeric values. Use these to set a RWDecimal<T> to a non-numeric value or to test for a specific non-numeric value.
Reimplemented from RWDecimal< M >.
© 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.