OnixS CME Drop Copy Handler C++ library  5.6.0
API documentation
Decimal Class Reference

#include <OnixS/CME/DropCopy/Numeric.h>

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 43 of file Numeric.h.

Constructor & Destructor Documentation

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

Initializes instance from compound components.

Definition at line 170 of file Numeric.h.

Decimal ( Double  value,
size_t  precision 
)

Converts Double value to decimal.

Parameters
valuedouble precision floating-point value.
precisiondefines conversion precision.
Decimal ( const Decimal other)
inline

Initializes as copy of given value.

Definition at line 176 of file Numeric.h.

Member Function Documentation

DecimalExponent exponent ( ) const
inline

Returns exponent part of decimal.

Definition at line 192 of file Numeric.h.

void exponent ( DecimalExponent  value)
inline

Updates exponent part of decimal.

Definition at line 197 of file Numeric.h.

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 298 of file Numeric.h.

DecimalMantissa mantissa ( ) const
inline

Returns mantissa part of decimal.

Definition at line 182 of file Numeric.h.

void mantissa ( DecimalMantissa  value)
inline

Updates mantissa part of decimal.

Definition at line 187 of file Numeric.h.

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 250 of file Numeric.h.

operator Int32 ( ) const
inline

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

Exceptions
domain_errorexception on failure.

Definition at line 210 of file Numeric.h.

operator Int64 ( ) const
inline

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

Exceptions
domain_errorexception on failure.

Definition at line 230 of file Numeric.h.

operator UInt32 ( ) const
inline

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

Exceptions
domain_errorexception on failure.

Definition at line 220 of file Numeric.h.

operator UInt64 ( ) const
inline

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

Exceptions
domain_errorexception on failure.

Definition at line 240 of file Numeric.h.

bool operator!= ( const Decimal ) const

Compares two numbers.

bool operator< ( const Decimal ) const

Establishes order between two values.

Decimal & operator= ( const Decimal other)
inline

Reinitializes instance from another one.

Definition at line 202 of file Numeric.h.

bool operator== ( const Decimal ) const

Compares two numbers.

bool operator> ( const Decimal ) const

Establishes order between two values.

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

Parses decimal from string presentation.

Exceptions
std::exceptionon failure.
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 292 of file Numeric.h.

bool toNumber ( Int32 ) const

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

Returns
false if conversion fails.
bool toNumber ( UInt32 ) const

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

Returns
false if conversion fails.
bool toNumber ( Int64 ) const

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

Returns
false if conversion fails.
bool toNumber ( UInt64 ) const

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

Returns
false if conversion fails.
bool toNumber ( Double ) const

Casts to double floating point number.

Returns
false if conversion fails.
void toString ( std::string &  ) const

Appends text presentation to given string.

std::string toString ( ) const
inline

Returns text presentation of decimal.

Definition at line 260 of file Numeric.h.

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

The documentation for this class was generated from the following file: