SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWFixedDecimal< M > Class Template Reference

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>

Inheritance diagram for RWFixedDecimal< M >:
RWDecimal< M >

Public Member Functions

 RWFixedDecimal ()
 
 RWFixedDecimal (const char *s)
 
 RWFixedDecimal (const RWDecimal< M > &d)
 
 RWFixedDecimal (const RWFixedDecimal< M > &d)
 
 RWFixedDecimal (int i)
 
 RWFixedDecimal (int x, int e)
 
 RWFixedDecimal (long int i)
 
 RWFixedDecimal (long int x, int e)
 
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)
 
RWFixedDecimal< M > & operator= (const RWFixedDecimal< M > &x)
 

Static Public Member Functions

static RWFixedDecimal< M > infinityValue ()
 
static RWFixedDecimal< M > missingValue ()
 
static RWFixedDecimal< M > NaNValue ()
 
static RWFixedDecimal< M > nullValue ()
 
static RWFixedDecimal< M > pow (const RWFixedDecimal< M > &x, int e)
 
static RWFixedDecimal< M > round (const RWFixedDecimal< M > &x, int n, RWDecimalBase::RoundingMethod rm)
 
static RWFixedDecimal< M > SNaNValue ()
 

Static Public Attributes

static const RWFixedDecimal< M > infinity
 
static const RWFixedDecimal< M > missing
 
static const RWFixedDecimal< M > NaN
 
static const RWFixedDecimal< M > null
 
static const RWFixedDecimal< M > SNaN
 

Related Symbols

(Note that these are not member symbols.)

template<class M >
RWFixedDecimal< M > abs (const RWFixedDecimal< M > &x)
 
template<class M >
bool operator!= (const RWFixedDecimal< M > &a, const RWFixedDecimal< 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, const RWDecimal< 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, double 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* (double a, const RWFixedDecimal< M > &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 RWDecimal< 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 RWFixedDecimal< 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 RWDecimal< 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 RWFixedDecimal< 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 char *a, const RWFixedDecimal< M > &b)
 
template<class M >
RWFixedDecimal< M > operator/ (const RWDecimal< M > &a, const RWFixedDecimal< M > &b)
 
template<class M >
RWFixedDecimal< M > operator/ (const RWDecimalPortable &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 RWFixedDecimal< M > &a, const RWDecimal< M > &b)
 
template<class M >
RWFixedDecimal< M > operator/ (const RWFixedDecimal< M > &a, const RWDecimalPortable &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, double 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/ (double a, const RWFixedDecimal< M > &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 >
bool operator< (const RWFixedDecimal< M > &a, const RWFixedDecimal< M > &b)
 
template<class M >
std::ostream & operator<< (std::ostream &strm, const RWFixedDecimal< M > &x)
 
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 >
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)
 
template<class M >
RWCString toString (const RWFixedDecimal< M > &d)
 

Additional Inherited Members

- Private Types inherited from RWDecimalBase
enum  Op {
  assign , add , sub , mult ,
  div , powop , pow10op , conversion
}
 
enum  RoundingMethod {
  PLAIN , UP , DOWN , BANKERS ,
  TRUNCATE
}
 
enum  State {
  normal , nullstate , NaNstate , ctorError ,
  missingstate , SNaNstate , infinitystate
}
 
- Private Member Functions inherited from RWDecimal< M >
 RWDecimal ()
 
 RWDecimal (const char *str)
 
 RWDecimal (const RWDecimal< M > &d)
 
 RWDecimal (const RWDecimalPortable &)
 
 RWDecimal (int i)
 
 RWDecimal (int m, int e)
 
 RWDecimal (long int i)
 
 RWDecimal (long int m, int e)
 
int decimalPlaces () const
 
int isNumber () const
 
 operator RWDecimalPortable () const
 
RWDecimal< M > & operator*= (const RWDecimal< M > &a)
 
RWDecimal< M > operator+ () const
 
RWDecimal< M > & operator+= (const RWDecimal< M > &a)
 
RWDecimal< M > operator- () const
 
RWDecimal< M > & operator-= (const RWDecimal< M > &a)
 
RWDecimal< M > & operator/= (const RWDecimal< M > &a)
 
RWDecimal< M > & operator= (const RWDecimal< M > &a)
 
void restoreFrom (RWFile &)
 
void restoreFrom (RWvistream &)
 
void saveOn (RWFile &) const
 
void saveOn (RWvostream &) const
 
- Private Member Functions inherited from RWDecimalBase
void swap (RWDecimalBase &rhs)
 
- Static Private Member Functions inherited from RWDecimal< M >
static RWDecimal< M > from (double)
 
static RWDecimal< M > from (long double)
 
static RWDecimal< M > infinityValue ()
 
static int maxDigits ()
 
static RWDecimal< M > maxValue ()
 
static RWDecimal< M > minValue ()
 
static RWDecimal< M > missingValue ()
 
static RWDecimal< M > NaNValue ()
 
static RWDecimal< M > nullValue ()
 
static void setInexactHandler (void(*eh)(const RWDecimalInexactErr< M > &))
 
static void setOverflowHandler (void(*eh)(const RWDecimalOverflowErr< M > &))
 
static RWDecimal< M > SNaNValue ()
 
- Static Private Attributes inherited from RWDecimal< M >
static const RWDecimal< M > infinity
 
static const RWDecimal< M > missing
 
static const RWDecimal< M > NaN
 
static const RWDecimal< M > null
 
static const RWDecimal< M > SNaN
 

Detailed Description

template<class M>
class RWFixedDecimal< M >

RWFixedDecimal 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 classes. The exception is that rounding automatically occurs to ensure the correct number of decimal places.

RWFixedDecimal is templatized. Three short type names are provided: RWFixedDecimal, RWFixedDecimal, and RWFixedDecimal. 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 class. Throughout this section, when we refer to the RWFixedDecimal class, you can assume that it applies to any of the three provided classes, or to one you have defined.

Synopsis
#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
Exact representation of a decimal fraction with a fixed number of digits after the decimal point,...
Definition fixeddec.h:224

The following header files are available for backward compatibility:

#include <rw/fixdec52.h> // RWFixedDecimal52
#include <rw/fixdec64.h> // RWFixedDecimal64
#include <rw/fixdec96.h> // RWFixedDecimal96
Example
#include <rw/currency/fixeddec.h>
#include <rw/currency/mp2int.h>
#include <iostream>
int main() {
RWFixedDecimal<RWMP2Int> penny = "0.01";
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;
}

Limits

Class RWFixedDecimal provides three static member functions that can be used to define the limits on an RWFixedDecimal object. These functions return the precision, maximum value, and minimum value:

Note that the precision returned by maxDigits() does not usually represent the number of digits in the largest possible RWFixedDecimal 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 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:
// Add 1 to max to generate an overflow error:
// Set min to minimum value:
// Subtract 1 from min to generate an overflow error:
RWFixedDecimal()
Definition fixeddec.h:327

Table 6 indicates the minimum and maximum values for RWFixedDecimal when T is replaced by one of the provided multiprecision integer types:

Table 6: Minimum and maximum values for RWFixedDecimal<T>
Class Minimum value Max Digits
Maximum value
RWDecimal -39614081257132168796771975167 28
39614081257132168796771975167
RWDecimal -9223372036854775807 18
9223372036854775807
RWDecimal -9007199254740991 15
9007199254740991

Non-Numeric Values

As well as representing a decimal fraction, an RWFixedDecimal 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 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 has a numeric value.

Arithmetic

For the most part, arithmetic between RWFixedDecimal objects is defined very simply: you get back an exact representation of the result of the operation. There are several special cases, however:

  • Loss of precision . If the result cannot be exactly represented as an RWFixedDecimal object because it has more than 18 significant digits, then the result is set to an approximation of the true result, and the inexact error handler is called.
  • Overflow/underflow . If the magnitude of the result exceeds the range of RWFixedDecimal, then the overflow error handler is called.
  • Operand of missing. If one of the operands is the value missing, then the result of the arithmetic operation is also a missing.
  • Operand of null. If both operands are null, the result is also null. In addition and subtraction, a null value behaves as if it were zero. In multiplication, a null behaves like a one. Dividing by a null value returns the numerator, i.e., a null in the denominator behaves like one. Using a null as the numerator in a division returns an NaN.

Constructor & Destructor Documentation

◆ RWFixedDecimal() [1/8]

template<class M >
RWFixedDecimal< M >::RWFixedDecimal ( )
inline

Constructs an RWFixedDecimal with a value of null.

◆ RWFixedDecimal() [2/8]

template<class M >
RWFixedDecimal< M >::RWFixedDecimal ( const RWFixedDecimal< M > & d)
inline

Copy constructor. Constructs an RWFixedDecimal that is a copy of the argument.

◆ RWFixedDecimal() [3/8]

template<class M >
RWFixedDecimal< M >::RWFixedDecimal ( const RWDecimal< M > & d)
inline

Constructs an RWFixedDecimal that represents the same value as the parameter. The number of decimal places is fixed to be the same as the parameter.

◆ RWFixedDecimal() [4/8]

template<class M >
RWFixedDecimal< M >::RWFixedDecimal ( int i)
inline

Constructs an RWFixedDecimal 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() [5/8]

template<class M >
RWFixedDecimal< M >::RWFixedDecimal ( long int i)
inline

Constructs an RWFixedDecimal with value i.

◆ RWFixedDecimal() [6/8]

template<class M >
RWFixedDecimal< M >::RWFixedDecimal ( int x,
int e )
inline

Constructs an RWFixedDecimal with value x*10-e where e represents the number of digits after the decimal point.

◆ RWFixedDecimal() [7/8]

template<class M >
RWFixedDecimal< M >::RWFixedDecimal ( long int x,
int e )
inline

Constructs an RWFixedDecimal with value x*10-e where e represents the number of digits after the decimal point.

◆ RWFixedDecimal() [8/8]

template<class M >
RWFixedDecimal< M >::RWFixedDecimal ( const char * s)
inline

Constructs an RWDecimal from the null terminated character string s. Since we write numbers using base 10 and the RWDecimal 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 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.

Member Function Documentation

◆ infinityValue()

template<class M >
static RWFixedDecimal< M > RWFixedDecimal< M >::infinityValue ( )
static
Deprecated
As of SourcePro 13, use RWFixedDecimal<M>::infinity.

Specifies the non-numeric value infinity. Use this function to test or to set its value on an RWFixedDecimal.

◆ missingValue()

template<class M >
static RWFixedDecimal< M > RWFixedDecimal< M >::missingValue ( )
static
Deprecated
As of SourcePro 13, use RWFixedDecimal<M>::missing.

Specifies the non-numeric value missing. Use this function to test or to set its value on an RWFixedDecimal.

◆ NaNValue()

template<class M >
static RWFixedDecimal< M > RWFixedDecimal< M >::NaNValue ( )
static
Deprecated
As of SourcePro 13, use RWFixedDecimal<M>::NaN.

Specifies the non-numeric value NaN. Use this function to test or to set its value on an RWFixedDecimal.

◆ nullValue()

template<class M >
static RWFixedDecimal< M > RWFixedDecimal< M >::nullValue ( )
static
Deprecated
As of SourcePro 13, use RWFixedDecimal<M>::null.

Specifies the non-numeric value null. Use this function to test or to set its value on an RWFixedDecimal.

◆ operator*=()

template<class M >
RWFixedDecimal< M > & RWFixedDecimal< M >::operator*= ( const RWFixedDecimal< M > & a)
inline

Performs a multiplication of self and a, and stores the result in self.

◆ operator+=()

template<class M >
RWFixedDecimal< M > & RWFixedDecimal< M >::operator+= ( const RWFixedDecimal< M > & a)
inline

Performs an addition of self and a, and stores the result in self.

◆ operator-=()

template<class M >
RWFixedDecimal< M > & RWFixedDecimal< M >::operator-= ( const RWFixedDecimal< M > & a)
inline

Performs a subtraction of a from self, and stores the result in self.

◆ operator/=()

template<class M >
RWFixedDecimal< M > & RWFixedDecimal< M >::operator/= ( const RWFixedDecimal< M > & a)
inline

Performs a division of self by a, and stores the result in self.

◆ operator=()

template<class M >
RWFixedDecimal< M > & RWFixedDecimal< M >::operator= ( const RWFixedDecimal< M > & x)

Sets value of self equal to the value of the argument.

◆ pow()

template<class M >
static RWFixedDecimal< M > RWFixedDecimal< M >::pow ( const RWFixedDecimal< M > & x,
int e )
inlinestatic

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.

◆ round()

template<class M >
static RWFixedDecimal< M > RWFixedDecimal< M >::round ( const RWFixedDecimal< M > & x,
int n,
RWDecimalBase::RoundingMethod rm )
inlinestatic

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.

◆ SNaNValue()

template<class M >
static RWFixedDecimal< M > RWFixedDecimal< M >::SNaNValue ( )
static
Deprecated
As of SourcePro 13, use RWFixedDecimal<M>::SNaN.

Specifies the non-numeric value SNaN. Use this function to test or to set its value on an RWFixedDecimal.

Friends And Related Symbol Documentation

◆ abs()

template<class M >
RWFixedDecimal< M > abs ( const RWFixedDecimal< M > & x)
related

Returns the absolute value of x.

◆ operator!=()

template<class M >
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.

◆ operator*() [1/9]

template<class M >
RWFixedDecimal< M > operator* ( const RWDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Multiplication operator.

◆ operator*() [2/9]

template<class M >
RWFixedDecimal< M > operator* ( const RWFixedDecimal< M > & a,
const RWDecimal< M > & b )
related

Multiplication operator.

◆ operator*() [3/9]

template<class M >
RWFixedDecimal< M > operator* ( const RWFixedDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Multiplication operator.

◆ operator*() [4/9]

template<class M >
RWFixedDecimal< M > operator* ( const RWFixedDecimal< M > & a,
double b )
related

Multiplication operator.

◆ operator*() [5/9]

template<class M >
RWFixedDecimal< M > operator* ( const RWFixedDecimal< M > & a,
int b )
related

Multiplication operator.

◆ operator*() [6/9]

template<class M >
RWFixedDecimal< M > operator* ( const RWFixedDecimal< M > & a,
long b )
related

Multiplication operator.

◆ operator*() [7/9]

template<class M >
RWFixedDecimal< M > operator* ( double a,
const RWFixedDecimal< M > & b )
related

Multiplication operator.

◆ operator*() [8/9]

template<class M >
RWFixedDecimal< M > operator* ( int a,
const RWFixedDecimal< M > & b )
related

Multiplication operator.

◆ operator*() [9/9]

template<class M >
RWFixedDecimal< M > operator* ( long a,
const RWFixedDecimal< M > & b )
related

Multiplication operator.

◆ operator+() [1/7]

template<class M >
RWFixedDecimal< M > operator+ ( const RWDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Addition operator

◆ operator+() [2/7]

template<class M >
RWFixedDecimal< M > operator+ ( const RWFixedDecimal< M > & a,
const RWDecimal< M > & b )
related

Addition operator

◆ operator+() [3/7]

template<class M >
RWFixedDecimal< M > operator+ ( const RWFixedDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Addition operator

◆ operator+() [4/7]

template<class M >
RWFixedDecimal< M > operator+ ( const RWFixedDecimal< M > & a,
int b )
related

Addition operator

◆ operator+() [5/7]

template<class M >
RWFixedDecimal< M > operator+ ( const RWFixedDecimal< M > & a,
long b )
related

Addition operator

◆ operator+() [6/7]

template<class M >
RWFixedDecimal< M > operator+ ( int a,
const RWFixedDecimal< M > & b )
related

Addition operator

◆ operator+() [7/7]

template<class M >
RWFixedDecimal< M > operator+ ( long a,
const RWFixedDecimal< M > & b )
related

Addition operator

◆ operator-() [1/7]

template<class M >
RWFixedDecimal< M > operator- ( const RWDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Subtraction operator.

◆ operator-() [2/7]

template<class M >
RWFixedDecimal< M > operator- ( const RWFixedDecimal< M > & a,
const RWDecimal< M > & b )
related

Subtraction operator.

◆ operator-() [3/7]

template<class M >
RWFixedDecimal< M > operator- ( const RWFixedDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Subtraction operator.

◆ operator-() [4/7]

template<class M >
RWFixedDecimal< M > operator- ( const RWFixedDecimal< M > & a,
int b )
related

Subtraction operator.

◆ operator-() [5/7]

template<class M >
RWFixedDecimal< M > operator- ( const RWFixedDecimal< M > & a,
long b )
related

Subtraction operator.

◆ operator-() [6/7]

template<class M >
RWFixedDecimal< M > operator- ( int a,
const RWFixedDecimal< M > & b )
related

Subtraction operator.

◆ operator-() [7/7]

template<class M >
RWFixedDecimal< M > operator- ( long a,
const RWFixedDecimal< M > & b )
related

Subtraction operator.

◆ operator/() [1/13]

template<class M >
RWFixedDecimal< M > operator/ ( const char * a,
const RWFixedDecimal< M > & b )
related

Division Operator

◆ operator/() [2/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Division Operator

◆ operator/() [3/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWDecimalPortable & a,
const RWFixedDecimal< M > & b )
related

Division Operator

◆ operator/() [4/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWFixedDecimal< M > & a,
const char * b )
related

Division Operator

◆ operator/() [5/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWFixedDecimal< M > & a,
const RWDecimal< M > & b )
related

Division Operator

◆ operator/() [6/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWFixedDecimal< M > & a,
const RWDecimalPortable & b )
related

Division Operator

◆ operator/() [7/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWFixedDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Division Operator

◆ operator/() [8/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWFixedDecimal< M > & a,
double b )
related

Division Operator

◆ operator/() [9/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWFixedDecimal< M > & a,
int b )
related

Division Operator

◆ operator/() [10/13]

template<class M >
RWFixedDecimal< M > operator/ ( const RWFixedDecimal< M > & a,
long b )
related

Division Operator

◆ operator/() [11/13]

template<class M >
RWFixedDecimal< M > operator/ ( double a,
const RWFixedDecimal< M > & b )
related

Division Operator

◆ operator/() [12/13]

template<class M >
RWFixedDecimal< M > operator/ ( int a,
const RWFixedDecimal< M > & b )
related

Division Operator

◆ operator/() [13/13]

template<class M >
RWFixedDecimal< M > operator/ ( long a,
const RWFixedDecimal< M > & b )
related

Division Operator

◆ operator<()

template<class M >
bool operator< ( const RWFixedDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Less than operator. If one (or both) of the operands is null or missing, then the result of the operator is undefined.

◆ operator<<()

template<class M >
std::ostream & operator<< ( std::ostream & strm,
const RWFixedDecimal< M > & x )
related

Writes an RWFixedDecimal 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.

◆ operator<=()

template<class M >
bool operator<= ( const RWFixedDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Less than or equal to operator. If one (or both) of the operands is null or missing, then the result of the operator is undefined.

◆ operator==()

template<class M >
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.

◆ operator>()

template<class M >
bool operator> ( const RWFixedDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Greater than operator. If one (or both) of the operands is null or missing, then the result of the operator is undefined.

◆ operator>=()

template<class M >
bool operator>= ( const RWFixedDecimal< M > & a,
const RWFixedDecimal< M > & b )
related

Greater than or equal to operator. If one (or both) of the operands is null or missing, then the result of the operator is undefined.

◆ operator>>()

template<class M >
std::istream & operator>> ( std::istream & strm,
RWFixedDecimal< M > & x )
related

Reads an RWFixedDecimal 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 class stores numbers using base 10, the number constructed is an exact representation of the input.

◆ toDouble()

template<class M >
long double toDouble ( const RWFixedDecimal< M > & d)
related

Converts the argument to a double precision value close to its true value.

◆ toInt() [1/2]

template<class M >
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().

◆ toInt() [2/2]

template<class M >
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().

◆ toString()

template<class M >
RWCString toString ( const RWFixedDecimal< M > & d)
related

Converts an RWFixedDecimal 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.

Member Data Documentation

◆ infinity

template<class M >
const RWFixedDecimal<M> RWFixedDecimal< M >::infinity
static

Specifies the non-numeric value infinity. Use this static instance to test or to set its value on an RWFixedDecimal.

◆ missing

template<class M >
const RWFixedDecimal<M> RWFixedDecimal< M >::missing
static

Specifies the non-numeric value missing. Use this static instance to test or to set its value on an RWFixedDecimal.

◆ NaN

template<class M >
const RWFixedDecimal<M> RWFixedDecimal< M >::NaN
static

Specifies the non-numeric value NaN. Use this static instance to test or to set its value on an RWFixedDecimal.

◆ null

template<class M >
const RWFixedDecimal<M> RWFixedDecimal< M >::null
static

Specifies the non-numeric value null. Use this static instance to test or to set its value on an RWFixedDecimal.

◆ SNaN

template<class M >
const RWFixedDecimal<M> RWFixedDecimal< M >::SNaN
static

Specifies the non-numeric value SNaN. Use this static instance to test or to set its value on an RWFixedDecimal.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.