OnixS CBOE CMi2 Trading Handler for C++  1.1.3.0
Public Member Functions | Static Public Member Functions | List of all members
Decimal Class Reference

Decimal type for better precision. More...

Public Member Functions

 Decimal ()
 Default constructor. More...
 
 Decimal (DecimalMantissa mantissa, DecimalExponent exponent)
 Initializes instance from compound components. More...
 
 Decimal (SInt32 value)
 Initializes instance with zero exponent. More...
 
 Decimal (Double value)
 Converts from Double value using default conversion precision. More...
 
 Decimal (Double value, size_t precision)
 Converts Double value to decimal. More...
 
 Decimal (const Decimal &other)
 Initializes as copy of given value. More...
 
DecimalMantissa mantissa () const
 Returns mantissa part of decimal. More...
 
DecimalExponent exponent () const
 Returns exponent part of decimal. More...
 
bool operator== (const Decimal &) const
 Compares two numbers. More...
 
bool operator!= (const Decimal &) const
 Compares two numbers. More...
 
 operator SInt32 () const
 Casts to whole integer number as regular floating point value is casted. More...
 
 operator UInt32 () const
 Casts to whole integer number as regular floating point value is casted. More...
 
 operator SInt64 () const
 Casts to whole integer number as regular floating point value is casted. More...
 
 operator UInt64 () const
 Casts to whole integer number as regular floating point value is casted. More...
 
 operator Double () const
 Casts to whole floating point as regular value is casted to a smaller precision. More...
 
bool toNumber (SInt32 &) const
 Casts to whole integer number as regular floating point value is casted. More...
 
bool toNumber (UInt32 &) const
 Casts to whole integer number as regular floating point value is casted. More...
 
bool toNumber (SInt64 &) const
 Casts to whole integer number as regular floating point value is casted. More...
 
bool toNumber (UInt64 &) const
 Casts to whole integer number as regular floating point value is casted. More...
 
bool toNumber (Double &) const
 Casts to floating point number. More...
 
void toString (std::string &) const
 Appends text presentation to given string. More...
 
std::string toString () const
 Returns text presentation of decimal. More...
 
Decimaloperator= (const Decimal &other)
 Reinitializes instance from another one. More...
 

Static Public Member Functions

static bool tryParse (const char *buffer, size_t bufferSize, Decimal &)
 Attempts to parse decimal value from its string/text presentation. More...
 
static Decimal parse (const char *buffer, size_t bufferSize)
 Parses decimal from string presentation. More...
 

Detailed Description

Decimal type for better precision.

Constructor & Destructor Documentation

Decimal ( )
inline

Default constructor.

Initializes the decimal value to zero.

Decimal ( DecimalMantissa  mantissa,
DecimalExponent  exponent 
)

Initializes instance from compound components.

Decimal ( SInt32  value)
explicit

Initializes instance with zero exponent.

Decimal ( Double  value)
explicit

Converts from Double value using default conversion precision.

Decimal ( Double  value,
size_t  precision 
)

Converts Double value to decimal.

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

Initializes as copy of given value.

Member Function Documentation

DecimalExponent exponent ( ) const
inline

Returns exponent part of decimal.

DecimalMantissa mantissa ( ) const
inline

Returns mantissa part of decimal.

operator Double ( ) const
inline

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

Exceptions
domain_errorexception on failure.
operator SInt32 ( ) const
inline

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

Exceptions
domain_errorexception on failure.
operator SInt64 ( ) const
inline

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

Exceptions
domain_errorexception on failure.
operator UInt32 ( ) const
inline

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

Exceptions
domain_errorexception on failure.
operator UInt64 ( ) const
inline

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

Exceptions
domain_errorexception on failure.
bool operator!= ( const Decimal ) const

Compares two numbers.

Decimal& operator= ( const Decimal other)

Reinitializes instance from another one.

bool operator== ( const Decimal ) const

Compares two numbers.

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

Parses decimal from string presentation.

Exceptions
std::exceptionon failure.
bool toNumber ( SInt32 &  ) 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 ( SInt64 &  ) 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 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.

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.