Purpose:
The DKDecimal class represents decimal variables that are representations of values scaled by a variable("scale") power of 10. The scale specifies the number of digits to the right of the decimal point, and ranges from 0 to 17. A scale of 0 means that there are no decimal places.
The largest possible value for a variable of this classis +/- 999999999999999999 with scale of 0. The smallest posible value for a variable of this class is +/-0.00000000000000001.
Since: Version 8
Class summary:
class DKDecimal { public: DKDecimal(); DKDecimal(short sValue); DKDecimal(int iValue); DKDecimal(long lValue); DKDecimal(char *strValue); DKDecimal(int unscaleInt, long scale); DKDecimal(long unscaleLong, long scale); DKDecimal(unsigned int uiValue); DKDecimal(unsigned long ulValue); DKDecimal(const DKDecimal &inDecimal); // assignment operators DKDecimal& operator=(const DKDecimal& inDecimal); DKDecimal& operator=(const int iValue); DKDecimal& operator=(const unsigned int iValue); DKDecimal& operator=(const long lValue); DKDecimal& operator=(const unsigned long ulValue); DKBoolean operator==(const DKDecimal& other) const; // addition operators DKDecimal& operator+(const DKDecimal &inDecimal); DKDecimal& operator+(const int iValue); DKDecimal& operator+(const long lValue); DKDecimal& operator+(const unsigned long ulValue); // subtraction operators DKDecimal& operator-(const DKDecimal &inDecimal); DKDecimal& operator-(const int iValue); DKDecimal& operator-(const long lValue); DKDecimal& operator-(const unsigned long ulValue); // multiplication operators DKDecimal& operator*(const DKDecimal &inDecimal); DKDecimal& operator*(const int iValue); DKDecimal& operator*(const long lValue); DKDecimal& operator*(const unsigned long ulValue); // divition operators DKDecimal& operator/(const DKDecimal &inDecimal); DKDecimal& operator/(const int iValue); DKDecimal& operator/(const long lValue); DKDecimal& operator/(const unsigned long ulValue); // convertion methods int toInteger(); long toLong(); double toDouble(); DKString toString() const; unsigned long toULong(); long getScale(); DKDecimal& setScale(long newScale); };
Members:
Parameters:
sValue
Short integer to convert into a decimal variable.
Parameters:
iValue
Integer to convert into a decimal variable.
Parameters:
lValue
Long value to convert into a decimal variable.
Parameters:
uiValue
Unsigned integer variable to convert into a decimal variable.
Parameters:
ulValue
Unsigned long variable to convert into a decimal variable.
Parameters:
strValue
Character string variable to convert into a decimal variable.
Parameters:
unscaleInt
Unscaled integer to convert to a decimal variable scale, scale value for the
created decimal
Parameters:
unscaleLong
Unscaled long to convert to a decimal variable scale, scale value for the
created decimal decimal
Parameters:
inDecimal
Decimal variable to use as a template value for the new decimal variable to
be created
DKDecimal& operator=(const DKDecimal& inDecimal)
Assignment operator for assigning new values to the DKDecimal variable
based on the values in the DKDecimal input parameter.
Parameters:
inDecimal - Decimal variable whose values are to be used for assignment
of new values to this DKDecimal variable
DKDecimal& operator=(const int iValue)
Assignment operator for converting the current value of this existing
DKDecimal variable into a new value based on the integer in the input
parameter.
Parameters:
iValue - Integer to be used for converting the current value of this decimal
variable
DKDecimal& operator=(const unsigned int iValue)
Assignment operator for converting the current value of this existing
DKDecimal variable into a new value based on the unsigned integer in the input
parameter.
Parameters:
iValue - Unsigned integer to be used for converting the current value of this
decimal variable
DKDecimal& operator=(const long lValue)
Assignment operator for converting the current value of this existing
DKDecimal variable into a new value based on the long value in the input
parameter.
Parameters:
lValue - Long value to be used for converting the current value of this
decimal variable
DKDecimal& operator=(const unsigned long ulValue)
Assignment operator for converting the current value of this existing
DKDecimal variable into a new value based on the unsigned long value in the
input parameter.
Parameters:
ulValue - Unsigned long value to be used for converting the current value of
this decimal variable
DKDecimal& operator+(const DKDecimal &inDecimal)
Addition operator for adding the value of the DKDecimal in the input
parameter from the value of this existing DKDecimal variable. The
returned DKDecimal has a scale that is the larger of the scale of this
DKDecimal variable and the DKDecimal variable in the input parameter.
Parameters:
inDecimal - Decimal variable whose value is to be added to this decimal
variable.
DKDecimal& operator+(const int iValue)Addition operator that returns a DKDecimal variable whose value is the sum of the value of this DKDecimal variable and the integer parameter. The scale of the returned DKDecimal is equal to the scale of this DKDecimal variable.
Parameters:
iValue - Integer value to be added to the value of this decimal
variable.
DKDecimal& operator+(const long lValue)Addition operator that returns a DKDecimal variable whose value is the sum of the value of this DKDecimal variable and the long input parameter and whose scale is equal to the scale of this DKDecimal variable.
Parameters:
lValue - long value to be added to the value of this decimal variable
DKDecimal& operator+(const unsigned long ulValue)Addition operator that returns a DKDecimal variable whose value is the sum of the value of this DKDecimal variable and the unsigned long input parameter and whose scale is equal to the scale of this DKDecimal variable.
Parameters:
ulValue - Unsigned long value to be added to the value of this decimal
variable.
DKDecimal& operator*(const DKDecimal &inDecimal)
Product operator for multiplying the value of the DKDecimal in the input
parameter with the value of this existing DKDecimal variable. The
returned DKDecimal has a scale that is the larger of the scale of this
DKDecimal variable and the DKDecimal variable in the input parameter.
Parameters:
inDecimal - Decimal variable whose value is to be multiplied with the value
of this decimal variable.
DKDecimal& operator*(const int iValue)
Product operator that returns a DKDecimal variable whose value is the product
of the value of this DKDecimal variable and the integer parameter. The
scale of the returned DKDecimal is equal to the scale of this DKDecimal
variable.
Parameters:
iValue - Integer value to be multiplied with the value of this decimal
variable.
DKDecimal& operator*(const long lValue)
Product operator that returns a DKDecimal variable whose value is the product
of the value of this DKDecimal variable and the long parameter. The
scale of the returned DKDecimal is equal to the scale of this DKDecimal
variable.
Parameters:
lValue - Long value to be multiplied with the value of this decimal
variable.
DKDecimal& operator*(const unsigned long ulValue)
Product operator that returns a DKDecimal variable whose value is the product
of the value of this DKDecimal variable and the unsigned long
parameter. The scale of the returned DKDecimal is equal to the scale of
this DKDecimal variable.
Parameters:
ulValue - Unsigned long value to be multiplied with the value of this decimal
variable.
DKDecimal& operator/(const DKDecimal &inDecimal)
Division operator for dividing the value of this DKDecimal variable by the
value of the DKDecimal variable in the input parameter. The returned
DKDecimal has a scale that is the larger of the scale of this DKDecimal
variable and the DKDecimal variable in the input parameter.
Parameters:
inDecimal - Decimal variable whose value is to be used to divide the value of
this decimal variable.
DKDecimal& operator/(const int iValue)
Division operator that returns a DKDecimal variable whose value is obtained
by dividing the value of this DKDecimal variable by the value of the integer
parameter. The scale of the returned DKDecimal is equal to the scale of
this DKDecimal variable.
Parameters:
iValue - Integer variable whose value is to be used to divide the value of
this decimal variable.
DKDecimal& operator/(const long lValue)Division operator that returns a DKDecimal variable whose value is obtained by dividing the value of this DKDecimal variable by the value of the long parameter. The scale of the returned DKDecimal is equal to the scale of this DKDecimal variable.
Parameters:
lValue - Long variable whose value is to be used to divide the value of this
decimal variable.
DKDecimal& operator/(const unsigned long ulValue)
Division operator that returns a DKDecimal variable whose value is obtained
by dividing the value of this DKDecimal variable by the value of the unsigned
long parameter. The scale of the returned DKDecimal is equal to the
scale of this DKDecimal variable.
Parameters:
ulValue - Unsigned long variable whose value is to be used to divide the
value of this decimal variable.
DKDecimal& operator==(const DKDecimal& other)
The Equality operator allows two DKDecimal objects to be compared to see if
they are equal or not.
Parameters:
other - DKDecimal value to be compared for equality with this DKDecimal
variable.
Returns:
True, if the two values are equal. False, if they are not.
Important: If this DKDecimal variable has a fractional part,
this fractional part is not considered for the return value. If this
DKDecimal variable is too big to fit into an integer, the low-order 32 bits
are returned.
Returns: Equivalent integer value
Important: If this DKDecimal variable has a fractional part,
this fractional part is not considered for the return value b) If this
DKDecimal variable is too big to fit into a long, then the low-order 32 bits
are returned.
Returns: Equivalent long value.
Important: If the value in this DKDecimal variable is too
big to fit into a double, the undefined value "1.#INF000000" is
returned
Returns: Equivalent double value
Important: If this DKDecimal variable has a fractional part,
the fraction is not considered for the return. If this DKDecimal
variable is too big to fit into an unsigned long variable, then the low-order
32 bits are returned.
Returns: Equivalent unsigned long value
Returns: String representation of this decimal variable as an instance of DKString
Returns: Scale for this decimal variable
Parameters:
newScale - New scale value for this decimal variable
(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.