User Interface class. More...
#include <ilviews/dataccess/decimal.h>
Public Member Functions | |
IliDecimal () | |
This constructor initializes a decimal with an initial value of zero. | |
IliDecimal (const IliDecimal &) | |
This is the copy constructor of the IliDecimal class. | |
IliDecimal (IlDouble val) | |
This constructor initializes a decimal with an initial value. More... | |
IliDecimal (IlInt val) | |
This constructor initializes a decimal with an initial value. More... | |
IliDecimal | abs () const |
Returns the absolute value of the decimal. More... | |
IlDouble | asDouble () const |
Returns a double value. More... | |
IlInt | asInt () const |
Returns a integer value. More... | |
int | compareTo (const IliDecimal &dec) const |
Compares two decimals. More... | |
IlInt | getPrecision () const |
Returns the precision of the decimal. More... | |
IlInt | getScale () const |
Returns the scale of the decimal. More... | |
IlInt | getSign () const |
Returns the sign of the value. More... | |
int | operator!= (const IliDecimal &dec) const |
Compares two decimals. More... | |
IliDecimal | operator* (const IliDecimal &dec) const |
Returns the product of the both decimals. More... | |
IliDecimal | operator+ (const IliDecimal &dec) const |
Returns the sum of the both decimals. More... | |
IliDecimal | operator- () const |
Returns the opposite value of the decimal. More... | |
IliDecimal | operator- (const IliDecimal &dec) const |
Returns the difference of the both decimals. More... | |
int | operator< (const IliDecimal &dec) const |
Compares two decimals. More... | |
int | operator<= (const IliDecimal &dec) const |
Compares two decimals. More... | |
const IliDecimal & | operator= (const IliDecimal &dec) |
Assigns another decimal object to the decimal object. More... | |
const IliDecimal & | operator= (IlDouble val) |
Assigns a double value to the decimal object. More... | |
const IliDecimal & | operator= (IlInt val) |
Assigns an integer value to the decimal object. More... | |
int | operator== (const IliDecimal &dec) const |
Compares two decimals. More... | |
int | operator> (const IliDecimal &dec) const |
Compares two decimals. More... | |
int | operator>= (const IliDecimal &dec) const |
Compares two decimals. More... | |
IlBoolean | setString (const char *value) |
Assigns a string value. More... | |
IlBoolean | toDouble (IlDouble &val) const |
Returns a double value. More... | |
IlBoolean | toInteger (IlInt &buff) const |
Returns an integer value. More... | |
char * | toString (char *buffer, int size) const |
Writes the value of the decimal in base 10 to a buffer. More... | |
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).
IliValue
.Name | Type | Equivalent methods |
---|---|---|
sign | Int | getSign() |
Name | Return type | Equivalent methods |
---|---|---|
toNumber() | Double | asDouble() |
toString() | String | toString() |
abs() | Object | abs() |
negate() | Object | operator-() |
compareTo(Object d) | Int | compareTo(d) |
add(Object d) | Object | operator+(d) |
substract(Object d) | Object | operator-(d) |
multiply(Object d) | Object | operator*(d) |
IliDecimal::IliDecimal | ( | IlInt | val | ) |
This constructor initializes a decimal with an initial value.
val | The initial value. |
IliDecimal::IliDecimal | ( | IlDouble | val | ) |
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.
val | The initial value. |
IliDecimal IliDecimal::abs | ( | ) | const |
Returns the absolute value of the decimal.
IlDouble IliDecimal::asDouble | ( | ) | const |
Returns a double value.
double
without loss of precision. Otherwise, it returns 0
. IlInt IliDecimal::asInt | ( | ) | const |
Returns a integer value.
int
without loss of precision. Otherwise, it returns 0
. int IliDecimal::compareTo | ( | const IliDecimal & | dec | ) | const |
Compares two decimals.
dec | The second decimal. |
+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.
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.
IlInt IliDecimal::getSign | ( | ) | const |
Returns the sign of the value.
+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.
dec | The second decimal. |
1
if the decimals are not equal, otherwise 0
. IliDecimal IliDecimal::operator* | ( | const IliDecimal & | dec | ) | const |
Returns the product of the both decimals.
dec | The second decimal. |
IliDecimal IliDecimal::operator+ | ( | const IliDecimal & | dec | ) | const |
Returns the sum of the both decimals.
dec | The second decimal. |
IliDecimal IliDecimal::operator- | ( | ) | const |
Returns the opposite value of the decimal.
IliDecimal IliDecimal::operator- | ( | const IliDecimal & | dec | ) | const |
Returns the difference of the both decimals.
dec | The second decimal. |
int IliDecimal::operator< | ( | const IliDecimal & | dec | ) | const |
Compares two decimals.
dec | The second decimal. |
1
if the decimal is smaller than the second decimal, otherwise 0
. int IliDecimal::operator<= | ( | const IliDecimal & | dec | ) | const |
Compares two decimals.
dec | The second decimal. |
1
if the decimal is smaller or equal than the second decimal, otherwise 0
. const IliDecimal& IliDecimal::operator= | ( | const IliDecimal & | dec | ) |
Assigns another decimal object to the decimal object.
dec | The new value. |
const IliDecimal& IliDecimal::operator= | ( | IlDouble | val | ) |
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.
val | The new value. |
const IliDecimal& IliDecimal::operator= | ( | IlInt | val | ) |
Assigns an integer value to the decimal object.
val | The new value. |
int IliDecimal::operator== | ( | const IliDecimal & | dec | ) | const |
Compares two decimals.
dec | The second decimal. |
1
if the decimals are equal, otherwise 0
. int IliDecimal::operator> | ( | const IliDecimal & | dec | ) | const |
Compares two decimals.
dec | The second decimal. |
1
if the decimal is greater than the second decimal, otherwise 0
. int IliDecimal::operator>= | ( | const IliDecimal & | dec | ) | const |
Compares two decimals.
dec | The second decimal. |
1
if the decimal is greater or equal than the second decimal, otherwise 0
. IlBoolean IliDecimal::setString | ( | const char * | value | ) |
Assigns a string value.
value | The representation in base 10 of a decimal number using the following syntax: [-|+]{digit}*[.[{digit}*]] or [-|+]{digit}+[.[{digit}*]][{E|e}[-|+]{digit}+] |
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.
val | The buffer which contains the double value. |
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.
buff | The buffer which contains the integer value. |
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.
buffer | Point to the character string. |
size | The string maximum size. |