Class managing large numbers. More...
#include <ilog/ilnum.h>
Public Member Functions | |
IlNumeric () | |
Builds an IlNumeric instance. More... | |
IlNumeric (const char *value) | |
Builds an IlNumeric instance and initializes it. More... | |
IlNumeric (long value) | |
Builds an IlNumeric instance an initializes it. More... | |
IlNumeric | abs () const |
void | get (char *buffer, IlInt len) const |
IlShort | getPrecision () const |
IlShort | getScale () const |
IlBoolean | isInteger () const |
IlBoolean | isNegative () const |
IlBoolean | isReal () const |
void | negate () |
operator double () const | |
operator long () const | |
IlNumeric | operator* (const IlNumeric &) |
IlNumeric | operator+ (const IlNumeric &) |
IlNumeric | operator+ (long) |
IlNumeric | operator- (const IlNumeric &) |
IlBoolean | operator< (const IlNumeric &n) const |
IlBoolean | operator<= (const IlNumeric &n) const |
IlBoolean | operator== (const IlNumeric &n) const |
IlBoolean | operator> (const IlNumeric &n) const |
IlBoolean | operator>= (const IlNumeric &n) const |
IlBoolean | set (const char *value) |
IlBoolean | set (long value) |
IlNumeric & | setScale (IlShort scale) |
Class managing large numbers.
Library: ilog
This class provides data members, member functions, and operators to manage large numbers as objects
. The constant IL_MAX_NUM_LEN
defines the maximum number of digits for the numbers that are handled by this class.
IlNumeric::IlNumeric | ( | ) |
IlNumeric::IlNumeric | ( | const char * | value | ) |
Builds an IlNumeric
instance and initializes it.
This constructor creates and returns an instance of IlNumeric
and initializes it with the contents of value. This value must conform to the format: [-|+]{digit}*[.[{digit}*]] | [-|+]{digit}+[.[{digit}*]][{E|e} [-|+]{digit}+]" The input string size is limited by the maximum length IL_MAX_NUM_LEN
.
value | A const reference to a char* . |
IlNumeric::IlNumeric | ( | long | value | ) |
IlNumeric IlNumeric::abs | ( | ) | const |
Returns the absolute value of the number as a new IlNumeric
object.
void IlNumeric::get | ( | char * | buffer, |
IlInt | len | ||
) | const |
Returns the value of the invoking instance of IlNumeric
in buffer as a string of maximum length len. The format is the same as for the input.
IlShort IlNumeric::getPrecision | ( | ) | const |
Returns the count of digits that make up the number represented by the object.
IlShort IlNumeric::getScale | ( | ) | const |
Returns the count of digits that make up the fractional part of the number.
IlBoolean IlNumeric::isInteger | ( | ) | const |
Returns IlTrue
if the numeric representation of the number fits in an integer type variable, or IlFalse
otherwise.
IlBoolean IlNumeric::isNegative | ( | ) | const |
Specifies whether the number is negative or not.
IlBoolean IlNumeric::isReal | ( | ) | const |
Returns IlTrue
if the numeric representation of the number needs a floating point variable, or IlFalse
otherwise.
void IlNumeric::negate | ( | ) |
Changes the sign of the number.
IlNumeric::operator double | ( | ) | const |
This coercer returns the floating-point value of the invoking instance of IlNumeric
.
IlNumeric::operator long | ( | ) | const |
This coercer returns the integer value of the invoking instance of IlNumeric
.
This operator returns a new IlNumeric
object equal to the product of the invoking instance and the argument.
This operator returns a new IlNumeric
object representing the sum of the invoking instance and the argument.
IlNumeric IlNumeric::operator+ | ( | long | ) |
This operator returns a new IlNumeric
object representing the sum of the invoking instance and the argument.
This operator returns a new IlNumeric
object equal to the difference between the invoking instance and the argument.
This predicate indicates whether the invoking instance is less than the argument.
This predicate indicates whether the invoking instance is less than or equal to the argument.
This predicate indicates whether two instances of IlNumeric
are equal.
This predicate indicates whether the invoking instance is strictly greater than the argument.
This predicate indicates whether the invoking instance is greater than or equal to the argument.
IlBoolean IlNumeric::set | ( | const char * | value | ) |
Assigns value as the value of the invoking instance of IlNumeric
. The input string must conform to the same format as the one given in the constructor.
IlBoolean IlNumeric::set | ( | long | value | ) |
Assigns value as the value of the invoking instance of IlNumeric
.