rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Data Access Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

IliDecimal Class Reference

User Interface class. More...

#include <ilviews/dataccess/decimal.h>

List of all members.

Public Member Functions

 IliDecimal (const IliDecimal &)
 This is the copy constructor of the IliDecimal class.
 IliDecimal (IlDouble val)
 This constructor initializes a decimal with an initial value.
 IliDecimal (IlInt val)
 This constructor initializes a decimal with an initial value.
 IliDecimal ()
 This constructor initializes a decimal with an initial value of zero.
IliDecimal abs () const
 Returns the absolute value of the decimal.
IlDouble asDouble () const
 Returns a double value.
IlInt asInt () const
 Returns a integer value.
int compareTo (const IliDecimal &dec) const
 Compares two decimals.
IlInt getPrecision () const
 Returns the precision of the decimal.
IlInt getScale () const
 Returns the scale of the decimal.
IlInt getSign () const
 Returns the sign of the value.
int operator!= (const IliDecimal &dec) const
 Compares two decimals.
IliDecimal operator* (const IliDecimal &dec) const
 Returns the product of the both decimals.
IliDecimal operator+ (const IliDecimal &dec) const
 Returns the sum of the both decimals.
IliDecimal operator- (const IliDecimal &dec) const
 Returns the difference of the both decimals.
IliDecimal operator- () const
 Returns the opposite value of the decimal.
int operator< (const IliDecimal &d) const
 Compares two decimals.
int operator<= (const IliDecimal &dec) const
 Compares two decimals.
const IliDecimaloperator= (IlDouble val)
 Assigns a double value to the decimal object.
const IliDecimaloperator= (IlInt val)
 Assigns an integer value to the decimal object.
const IliDecimaloperator= (const IliDecimal &dec)
 Assigns another decimal object to the decimal object.
int operator== (const IliDecimal &dec) const
 Compares two decimals.
int operator> (const IliDecimal &dec) const
 Compares two decimals.
int operator>= (const IliDecimal &dec) const
 Compares two decimals.
IlBoolean setString (const char *value)
 Assigns a string value.
IlBoolean toDouble (IlDouble &d) const
 Returns a double value.
IlBoolean toInteger (IlInt &buff) const
 Returns an integer value.
char * toString (char *buffer, int size) const
 Writes the value of the decimal in base 10 to a buffer.

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

Parameters:
val The 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:
dec The 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:
dec The 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:
dec The second decimal.
Returns:
The product of the both decimals.
IliDecimal IliDecimal::operator+ ( const IliDecimal dec  )  const

Returns the sum of the both decimals.

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

Returns the difference of the both decimals.

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

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:
dec The 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:
dec The second decimal.
Returns:
1 if the decimal is smaller or equal than the second decimal, otherwise 0.
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:
val The new value.
Returns:
The modified object.
const IliDecimal& IliDecimal::operator= ( IlInt  val  ) 

Assigns an integer value to the decimal object.

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

Assigns another decimal object to the decimal object.

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

Compares two decimals.

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

Compares two decimals.

Parameters:
dec The 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:
dec The 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:
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.
IlBoolean IliDecimal::toDouble ( IlDouble d  )  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:
val The 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:
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.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends

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