OnixS CME Drop Copy Handler C++ library 5.7.1
API documentation
Loading...
Searching...
No Matches
Decimal Class Reference

Public Member Functions

 Decimal (DecimalMantissa mantissa=0, DecimalExponent exponent=0)
 Decimal (Double value, size_t precision)
 Decimal (const Decimal &other)
DecimalMantissa mantissa () const
void mantissa (DecimalMantissa)
DecimalExponent exponent () const
void exponent (DecimalExponent)
bool operator== (const Decimal &) const
bool operator!= (const Decimal &) const
bool operator< (const Decimal &) const
bool operator> (const Decimal &) const
 operator Int32 () const
 operator UInt32 () const
 operator Int64 () const
 operator UInt64 () const
 operator Double () const
bool toNumber (Int32 &) const
bool toNumber (UInt32 &) const
bool toNumber (Int64 &) const
bool toNumber (UInt64 &) const
bool toNumber (Double &) const
Double toDoubleUnchecked () const
void toString (std::string &) const
std::string toString () const
Decimaloperator= (const Decimal &other)

Static Public Member Functions

static Decimal fromDoubleUnchecked (Double value, size_t precision)
static bool tryParse (const char *buffer, size_t bufferSize, Decimal &)
static Decimal parse (const char *buffer, size_t bufferSize)

Detailed Description

Definition at line 44 of file Numeric.h.

Constructor & Destructor Documentation

◆ Decimal() [1/3]

Decimal ( DecimalMantissa mantissa = 0,
DecimalExponent exponent = 0 )
inline

Initializes instance from compound components.

Definition at line 171 of file Numeric.h.

◆ Decimal() [2/3]

Decimal ( Double value,
size_t precision )

Converts Double value to decimal.

Parameters
valuedouble precision floating-point value.
precisiondefines conversion precision.

◆ Decimal() [3/3]

Decimal ( const Decimal & other)
inline

Initializes as copy of given value.

Definition at line 177 of file Numeric.h.

Member Function Documentation

◆ exponent() [1/2]

DecimalExponent exponent ( ) const
inline

Returns exponent part of decimal.

Definition at line 193 of file Numeric.h.

◆ exponent() [2/2]

void exponent ( DecimalExponent value)
inline

Updates exponent part of decimal.

Definition at line 198 of file Numeric.h.

◆ fromDoubleUnchecked()

Decimal fromDoubleUnchecked ( Double value,
size_t precision )
inlinestatic

Fast cast from double floating point number.

Note
For the sake of performance no range checks are done. Result may be invalid if decimal cannot be represented as double value. Warning: result may be different (less precise) from Decimal(Double, size_t) result due to performance vs precision trade-off.

Definition at line 306 of file Numeric.h.

◆ mantissa() [1/2]

DecimalMantissa mantissa ( ) const
inline

Returns mantissa part of decimal.

Definition at line 183 of file Numeric.h.

◆ mantissa() [2/2]

void mantissa ( DecimalMantissa value)
inline

Updates mantissa part of decimal.

Definition at line 188 of file Numeric.h.

◆ operator Double()

operator Double ( ) const
inline

Casts to whole floating point as regular value is casted to a smaller precision.

Exceptions
domain_errorexception on failure.

Definition at line 259 of file Numeric.h.

◆ operator Int32()

operator Int32 ( ) const
inline

Casts to whole integer number as regular floating point value is casted.

Exceptions
domain_errorexception on failure.

Definition at line 211 of file Numeric.h.

◆ operator Int64()

operator Int64 ( ) const
inline

Casts to whole integer number as regular floating point value is casted.

Exceptions
domain_errorexception on failure.

Definition at line 235 of file Numeric.h.

◆ operator UInt32()

operator UInt32 ( ) const
inline

Casts to whole integer number as regular floating point value is casted.

Exceptions
domain_errorexception on failure.

Definition at line 223 of file Numeric.h.

◆ operator UInt64()

operator UInt64 ( ) const
inline

Casts to whole integer number as regular floating point value is casted.

Exceptions
domain_errorexception on failure.

Definition at line 247 of file Numeric.h.

◆ operator!=()

bool operator!= ( const Decimal & ) const

Compares two numbers.

◆ operator<()

bool operator< ( const Decimal & ) const

Establishes order between two values.

◆ operator=()

Decimal & operator= ( const Decimal & other)
inline

Reinitializes instance from another one.

Definition at line 203 of file Numeric.h.

◆ operator==()

bool operator== ( const Decimal & ) const

Compares two numbers.

◆ operator>()

bool operator> ( const Decimal & ) const

Establishes order between two values.

◆ parse()

Decimal parse ( const char * buffer,
size_t bufferSize )
static

Parses decimal from string presentation.

Exceptions
std::exceptionon failure.

◆ toDoubleUnchecked()

Double toDoubleUnchecked ( ) const
inline

Fast cast to double floating point number.

Note
For the sake of performance no range checks are done. Result may be invalid if decimal cannot be represented as double value. Warning: result may be different (less precise) from toNumber(Double&) result due to performance vs precision trade-off.

Definition at line 300 of file Numeric.h.

◆ toNumber() [1/5]

bool toNumber ( Double & ) const

Casts to double floating point number.

Returns
false if conversion fails.

◆ toNumber() [2/5]

bool toNumber ( Int32 & ) const

Casts to whole integer number as regular floating point value is casted.

Returns
false if conversion fails.

◆ toNumber() [3/5]

bool toNumber ( Int64 & ) const

Casts to whole integer number as regular floating point value is casted.

Returns
false if conversion fails.

◆ toNumber() [4/5]

bool toNumber ( UInt32 & ) const

Casts to whole integer number as regular floating point value is casted.

Returns
false if conversion fails.

◆ toNumber() [5/5]

bool toNumber ( UInt64 & ) const

Casts to whole integer number as regular floating point value is casted.

Returns
false if conversion fails.

◆ toString() [1/2]

std::string toString ( ) const
inline

Returns text presentation of decimal.

Definition at line 271 of file Numeric.h.

◆ toString() [2/2]

void toString ( std::string & ) const

Appends text presentation to given string.

◆ tryParse()

bool tryParse ( const char * buffer,
size_t bufferSize,
Decimal &  )
static

Attempts to parse decimal value from its string/text presentation.

Returns
false on parsing failure.