CComCurrency Class
CComCurrency has methods and operators for creating and managing a CURRENCY object.
class CComCurrency
Members
Public Constructors
Name |
Description |
---|---|
The constructor for a CComCurrency object. |
Public Methods
Name |
Description |
---|---|
Returns the address of an m_currency data member. |
|
Call this method to return the fractional component of a CComCurrency object. |
|
Call this method to return the integer component of a CComCurrency object. |
|
Call this method to round a CComCurrency object to the nearest integer value. |
|
Call this method to set the fractional component of a CComCurrency object. |
|
Call this method to set the integer component of a CComCurrency object. |
Public Operators
Name |
Description |
---|---|
This operator is used to perform subtraction on a CComCurrency object. |
|
Compares two CComCurrency objects for inequality. |
|
This operator is used to perform multiplication on a CComCurrency object. |
|
This operator is used to perform multiplication on a CComCurrency object and assign it the result. |
|
This operator is used to perform division on a CComCurrency object. |
|
This operator is used to perform division on a CComCurrency object and assign it the result. |
|
This operator is used to perform addition on a CComCurrency object. |
|
This operator is used to perform addition on a CComCurrency object and assign the result to the current object. |
|
This operator compares two CComCurrency objects to determine the lesser. |
|
This operator compares two CComCurrency objects to determine equality or the lesser. |
|
This operator assigns the CComCurrency object to a new value. |
|
This operator is used to perform subtraction on a CComCurrency object and assign it the result. |
|
This operator compares two CComCurrency objects for equality. |
|
This operator compares two CComCurrency objects to determine the larger. |
|
This operator compares two CComCurrency objects to determine equality or the larger. |
|
Casts a CURRENCY object. |
Public Data Members
Name |
Description |
---|---|
The CURRENCY variable created by your class instance. |
Remarks
CComCurrency is a wrapper for the CURRENCY data type. CURRENCY is implemented as an 8-byte two's-complement integer value scaled by 10,000. This gives a fixed-point number with 15 digits to the left of the decimal point and 4 digits to the right. The CURRENCY data type is extremely useful for calculations involving money, or for any fixed-point calculations where accuracy is important.
The CComCurrency wrapper implements arithmetic, assignment, and comparison operations for this fixed-point type. The supported applications have been selected to control the rounding errors that can occur during fixed-point calculations.
The CComCurrency object provides access to the numbers on either side of the decimal point in the form of two components: an integer component which stores the value to the left of the decimal point, and a fractional component which stores the value to the right of the decimal point. The fractional component is stored internally as an integer value between -9999 (CY_MIN_FRACTION) and +9999 (CY_MAX_FRACTION). The method CComCurrency::GetFraction returns a value scaled by a factor of 10000 (CY_SCALE).
When specifying the integer and fractional components of a CComCurrency object, remember that the fractional component is a number in the range 0 to 9999. This is important when dealing with a currency such as the US dollar that expresses amounts using only two significant digits after the decimal point. Even though the last two digits are not displayed, they must be taken into account.
Value |
Possible CComCurrency assignments |
---|---|
$10.50 |
CComCurrency(10,5000) or CComCurrency(10.50) |
$10.05 |
CComCurrency(10,500) or CComCurrency(10.05) |
The values CY_MIN_FRACTION, CY_MAX_FRACTION, and CY_SCALE are defined in atlcur.h.
Requirements
Header: atlcur.h