IliDecimal Class Reference
User Interface class.
More...
#include <ilviews/dataccess/decimal.h>
List of all members.
Detailed Description
User Interface class.
Library: dataccess
The IliDecimal
class is used to hold fixed-point numbers with up to 38 digits of precision (internally represented in base 10). This contrasts with the C++ double type that represents floating-point numbers in base 2 and that has a machine-dependent precision (typically 15 digits).
- See also:
- IliValue
Constructor & Destructor Documentation
IliDecimal::IliDecimal |
( |
IlInt |
val |
) |
|
This constructor initializes a decimal with an initial value.
- Parameters:
-
This constructor initializes a decimal with an initial value.
Note that since the value is a double type (internally represented in base 2), the resulting value of the decimal may differ slightly due to rounding during the conversion.
- Parameters:
-
Member Function Documentation
Returns the absolute value of the decimal.
- Returns:
- The absolute value of the decimal.
Returns a double value.
- Returns:
- The corresponding double if the value can be stored into a
double
without loss of precision. Otherwise, it returns 0
.
IlInt IliDecimal::asInt |
( |
|
) |
const |
Returns a integer value.
- Returns:
- The corresponding integer if the value of the decimal is an integer and if it can be stored into an
int
without loss of precision. Otherwise, it returns 0
.
int IliDecimal::compareTo |
( |
const IliDecimal & |
dec |
) |
const |
Compares two decimals.
- Parameters:
-
- Returns:
+1
if the decimal is greater than dec
, 0
if they are equal, and -1
if the decimal is less than dec
.
IlInt IliDecimal::getPrecision |
( |
|
) |
const |
Returns the precision of the decimal.
This is the number of digits needed to represent its value in base 10.
- Returns:
- The precision.
IlInt IliDecimal::getScale |
( |
|
) |
const |
Returns the scale of the decimal.
This is the number of digits that fall after the decimal point when represented in base 10.
- Returns:
- The scale.
IlInt IliDecimal::getSign |
( |
|
) |
const |
Returns the sign of the value.
- Returns:
+1
if the value of the decimal is positive, 0
if it is zero, and -1
if it is negative.
int IliDecimal::operator!= |
( |
const IliDecimal & |
dec |
) |
const |
Compares two decimals.
- Parameters:
-
- Returns:
1
if the decimals are not equal, otherwise 0
.
Returns the product of the both decimals.
- Parameters:
-
- Returns:
- The product of the both decimals.
Returns the sum of the both decimals.
- Parameters:
-
- Returns:
- The sum of the both decimal objects.
Returns the difference of the both decimals.
- Parameters:
-
- Returns:
- The difference of the both decimals.
Returns the opposite value of the decimal.
- Returns:
- The opposite value of the decimal.
int IliDecimal::operator< |
( |
const IliDecimal & |
d |
) |
const |
Compares two decimals.
- Parameters:
-
- Returns:
1
if the decimal is smaller than the second decimal, otherwise 0
.
int IliDecimal::operator<= |
( |
const IliDecimal & |
dec |
) |
const |
Compares two decimals.
- Parameters:
-
- Returns:
1
if the decimal is smaller or equal than the second decimal, otherwise 0
.
Assigns a double value to the decimal object.
Note that since the value is a double (internally represented in base 2), the resulting value of the decimal may differ slightly due to rounding during conversion.
- Parameters:
-
- Returns:
- The modified object.
Assigns an integer value to the decimal object.
- Parameters:
-
- Returns:
- The modified object.
Assigns another decimal object to the decimal object.
- Parameters:
-
- Returns:
- The modified object.
int IliDecimal::operator== |
( |
const IliDecimal & |
dec |
) |
const |
Compares two decimals.
- Parameters:
-
- Returns:
1
if the decimals are equal, otherwise 0
.
int IliDecimal::operator> |
( |
const IliDecimal & |
dec |
) |
const |
Compares two decimals.
- Parameters:
-
- Returns:
1
if the decimal is greater than the second decimal, otherwise 0
.
int IliDecimal::operator>= |
( |
const IliDecimal & |
dec |
) |
const |
Compares two decimals.
- Parameters:
-
- Returns:
1
if the decimal is greater or equal than the second decimal, otherwise 0
.
IlBoolean IliDecimal::setString |
( |
const char * |
value |
) |
|
Assigns a string value.
- Parameters:
-
| value | The representation in base 10 of a decimal number using the following syntax: [-|+]{digit}*[.[{digit}*]] or [-|+]{digit}+[.[{digit}*]][{E|e}[-|+]{digit}+] |
- Returns:
IlTrue
if successful.
Returns a double value.
If the value of the decimal can be stored into a double without loss of precision, this member function stores the value of the decimal into the buffer.
- Parameters:
-
| val | The buffer which contains the double value. |
- Returns:
IlTrue
. Otherwise, it returns IlFalse
.
Returns an integer value.
If the value of the decimal is an integer and can be stored into an int
without loss of precision, this member function stores the value of this decimal into the buffer.
- Parameters:
-
| val | The buffer which contains the integer value. |
- Returns:
IlTrue
. Otherwise, it returns IlFalse
.
char* IliDecimal::toString |
( |
char * |
buffer, |
|
|
int |
size | |
|
) |
| | const |
Writes the value of the decimal in base 10 to a buffer.
- Parameters:
-
| buffer | Point to the character string. |
| size | The string maximum size. |
- Returns:
- The buffer.
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.