rwlogo

Rogue Wave Views
Data Access Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

 All Classes Files Functions Variables Typedefs Enumerations Enumerator
List of all members | Public Member Functions
IliDecimal Class Reference

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 (IlInt val)
 This constructor initializes a decimal with an initial value. More...
 
 IliDecimal (IlDouble val)
 This constructor initializes a decimal with an initial value. More...
 
 IliDecimal (const IliDecimal &)
 This is the copy constructor of the IliDecimal class.
 
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 IliDecimaloperator= (const IliDecimal &dec)
 Assigns another decimal object to the decimal object. More...
 
const IliDecimaloperator= (IlInt val)
 Assigns an integer value to the decimal object. More...
 
const IliDecimaloperator= (IlDouble val)
 Assigns a double 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...
 

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
valThe 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.

Parameters
valThe initial value.

Member Function Documentation

IliDecimal IliDecimal::abs ( ) const

Returns the absolute value of the decimal.

Returns
The absolute value of the decimal.
IlDouble IliDecimal::asDouble ( ) const

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
decThe second decimal.
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
decThe second decimal.
Returns
1 if the decimals are not equal, otherwise 0 .
IliDecimal IliDecimal::operator* ( const IliDecimal dec) const

Returns the product of the both decimals.

Parameters
decThe second decimal.
Returns
The product of the both decimals.
IliDecimal IliDecimal::operator+ ( const IliDecimal dec) const

Returns the sum of the both decimals.

Parameters
decThe second decimal.
Returns
The sum of the both decimal objects.
IliDecimal IliDecimal::operator- ( ) const

Returns the opposite value of the decimal.

Returns
The opposite value of the decimal.
IliDecimal IliDecimal::operator- ( const IliDecimal dec) const

Returns the difference of the both decimals.

Parameters
decThe second decimal.
Returns
The difference of the both decimals.
int IliDecimal::operator< ( const IliDecimal dec) const

Compares two decimals.

Parameters
decThe second decimal.
Returns
1 if the decimal is smaller than the second decimal, otherwise 0.
int IliDecimal::operator<= ( const IliDecimal dec) const

Compares two decimals.

Parameters
decThe second decimal.
Returns
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.

Parameters
decThe new value.
Returns
The modified object.
const IliDecimal& IliDecimal::operator= ( IlInt  val)

Assigns an integer value to the decimal object.

Parameters
valThe new value.
Returns
The modified object.
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.

Parameters
valThe new value.
Returns
The modified object.
int IliDecimal::operator== ( const IliDecimal dec) const

Compares two decimals.

Parameters
decThe second decimal.
Returns
1 if the decimals are equal, otherwise 0.
int IliDecimal::operator> ( const IliDecimal dec) const

Compares two decimals.

Parameters
decThe second decimal.
Returns
1 if the decimal is greater than the second decimal, otherwise 0.
int IliDecimal::operator>= ( const IliDecimal dec) const

Compares two decimals.

Parameters
decThe second decimal.
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
valueThe representation in base 10 of a decimal number using the following syntax: [-|+]{digit}*[.[{digit}*]] or [-|+]{digit}+[.[{digit}*]][{E|e}[-|+]{digit}+]
Returns
IlTrue if successful.
IlBoolean IliDecimal::toDouble ( IlDouble val) const

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
valThe buffer which contains the double value.
Returns
IlTrue. Otherwise, it returns IlFalse.
IlBoolean IliDecimal::toInteger ( IlInt buff) const

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
buffThe 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
bufferPoint to the character string.
sizeThe string maximum size.
Returns
The buffer.

© Copyright 2015, 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.