OnixS CME Drop Copy Handler for C++  5.3.0.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 (DecimalMantissa mantissa=0, DecimalExponent exponent=0)
 Initializes instance from compound components.
 
 Decimal (Double value, size_t precision)
 Converts Double value to decimal. More...
 
 Decimal (const Decimal &other)
 Initializes as copy of given value.
 
DecimalMantissa mantissa () const
 Returns mantissa part of decimal.
 
void mantissa (DecimalMantissa)
 Updates mantissa part of decimal.
 
DecimalExponent exponent () const
 Returns exponent part of decimal.
 
void exponent (DecimalExponent)
 Updates exponent part of decimal.
 
bool operator== (const Decimal &) const
 Compares two numbers.
 
bool operator!= (const Decimal &) const
 Compares two numbers.
 
bool operator< (const Decimal &) const
 Establishes order between two values.
 
bool operator> (const Decimal &) const
 Establishes order between two values.
 
 operator Int32 () 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 Int64 () 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 (Int32 &) 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 (Int64 &) 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 double floating point number. More...
 
Double toDoubleUnchecked () const
 Fast cast to double floating point number. More...
 
void toString (std::string &) const
 Appends text presentation to given string.
 
std::string toString () const
 Returns text presentation of decimal.
 
Decimaloperator= (const Decimal &other)
 Reinitializes instance from another one.
 

Static Public Member Functions

static Decimal fromDoubleUnchecked (Double value, size_t precision)
 Fast cast from double floating point number. More...
 
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 ( Double  value,
size_t  precision 
)

Converts Double value to decimal.

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

Member Function Documentation

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 precison trade-off.
operator Double ( ) const
inline

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

Exceptions
domain_errorexception on failure.
operator Int32 ( ) const
inline

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

Exceptions
domain_errorexception on failure.
operator Int64 ( ) 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.
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 precison trade-off.
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.
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.