EPAM B2BITS C++ Bovespa MarketData handler  1.28.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
B2bits::Decimal Class Reference

Encapsulates float type. More...

#include <b2bits/types/Decimal.h>

Public Member Functions

i64 getMantissa () const noexcept
 
i32 getExponent () const noexcept
 
i64 mantissa () const noexcept
 
i32 exponent () const noexcept
 
float toFloat () const
 
double toDouble () const
 
bool equals (const Decimal &rv) const
 
 Decimal ()
 Default contructor. More...
 
 Decimal (i64 m, i32 e)
 
 Decimal (double v) noexcept
 
 Decimal (i64 x) noexcept
 
Decimal changeExponent (i32 newExponent) const
 
char * toString (char *buf) const
 
std::string toStdString () const
 
char * toString (char *buf, std::size_t size) const
 
bool operator== (Decimal const &val) const
 
bool operator!= (Decimal const &val) const
 
bool operator> (Decimal const &val) const
 
bool operator< (Decimal const &val) const
 
bool operator>= (Decimal const &val) const
 
bool operator<= (Decimal const &val) const
 
Decimaloperator+= (Decimal const &val) noexcept
 
Decimal operator+ (Decimal const &val) const noexcept
 
Decimaloperator++ () noexcept
 Prefix increment. More...
 
Decimal operator++ (int) noexcept
 Postfix increment. More...
 
Decimaloperator-= (Decimal const &val) noexcept
 
Decimal operator- (Decimal const &val) const noexcept
 
Decimaloperator-- () noexcept
 Prefix decrement. More...
 
Decimal operator-- (int) noexcept
 Postfix decrement. More...
 
Decimal operator* (Decimal const &val) const noexcept
 Multiplication operator. More...
 
Decimaloperator*= (Decimal const &val) noexcept
 Multiplication assignment. More...
 

Static Public Member Functions

static Decimal fromString (AsciiString str)
 Converts string to Decimal. More...
 
static Decimal fromFixString (AsciiString str) noexcept
 Converts string to Decimal. More...
 
static Decimal fromDouble (double v, int precision)
 
static Decimal fromDouble (double v)
 

Static Public Attributes

static unsigned int const ValueSize = 2 + 63 + sizeof( "18446744073709551616" )
 Maximum buffer size required to store value. More...
 

Detailed Description

Encapsulates float type.

Constructor & Destructor Documentation

B2bits::Decimal::Decimal ( )
inline

Default contructor.

B2bits::Decimal::Decimal ( i64  m,
i32  e 
)
inline

Contructor Constructs object from mantissa and exponent

Parameters
mMantissa
eExponent
B2bits::Decimal::Decimal ( double  v)
noexcept

Contructor Constructs object from double

Parameters
vValue of the double type
B2bits::Decimal::Decimal ( i64  x)
noexcept

Contructor Constructs object from 64-bit integer

Parameters
xValue of the i64 type

Member Function Documentation

Decimal B2bits::Decimal::changeExponent ( i32  newExponent) const

Returns new Decimal value with required exponent.

Parameters
newExponentRequired exponent. Must be in range [currentExponent-18 .. currentExponent+18]
bool B2bits::Decimal::equals ( const Decimal rv) const

Compares two Decimals

Parameters
rvValue to compare with.
Returns
true if equals; false otherwise
i32 B2bits::Decimal::exponent ( ) const
inlinenoexcept

Returns exponent part of the value

Returns
exponent part of the value
static Decimal B2bits::Decimal::fromDouble ( double  v,
int  precision 
)
static

Contructor Constructs object from double

Warning
This method is lossy.
Parameters
vValue of the double type
precisionNumber of digits after point. Must be in range [0..17]
static Decimal B2bits::Decimal::fromDouble ( double  v)
static

Contructor Constructs object from double

Warning
This method is lossy.
Parameters
vValue of the double type
static Decimal B2bits::Decimal::fromFixString ( AsciiString  str)
inlinestaticnoexcept

Converts string to Decimal.

static Decimal B2bits::Decimal::fromString ( AsciiString  str)
static

Converts string to Decimal.

i32 B2bits::Decimal::getExponent ( ) const
inlinenoexcept

Returns exponent part of the value

Returns
exponent part of the value
i64 B2bits::Decimal::getMantissa ( ) const
inlinenoexcept

Returns mantissa part of the value

Returns
mantissa part of the value
i64 B2bits::Decimal::mantissa ( ) const
inlinenoexcept

Returns mantissa part of the value

Returns
mantissa part of the value
bool B2bits::Decimal::operator!= ( Decimal const &  val) const
inline

Compares two decimals.

Returns
true if two decimals are NOT equal; false otherwise.
Decimal B2bits::Decimal::operator* ( Decimal const &  val) const
inlinenoexcept

Multiplication operator.

Decimal& B2bits::Decimal::operator*= ( Decimal const &  val)
inlinenoexcept

Multiplication assignment.

Decimal B2bits::Decimal::operator+ ( Decimal const &  val) const
inlinenoexcept

Addition operator

Note
Please note this method works only if both decimal have same exponent
Decimal& B2bits::Decimal::operator++ ( )
inlinenoexcept

Prefix increment.

Decimal B2bits::Decimal::operator++ ( int  )
inlinenoexcept

Postfix increment.

Decimal& B2bits::Decimal::operator+= ( Decimal const &  val)
inlinenoexcept

Addition assignment

Note
Please note this method works only if both decimal have same exponent
Decimal B2bits::Decimal::operator- ( Decimal const &  val) const
inlinenoexcept

Substraction operator

Note
Please note this method works only if both decimal have same exponent
Decimal& B2bits::Decimal::operator-- ( )
inlinenoexcept

Prefix decrement.

Decimal B2bits::Decimal::operator-- ( int  )
inlinenoexcept

Postfix decrement.

Decimal& B2bits::Decimal::operator-= ( Decimal const &  val)
inlinenoexcept

Subtraction assignment

Note
Please note this method works only if both decimal have same exponent
bool B2bits::Decimal::operator< ( Decimal const &  val) const
inline

Compares two decimals.

Returns
true if left decimal is smaller than right; false otherwise.
bool B2bits::Decimal::operator<= ( Decimal const &  val) const
inline

Compares two decimals.

Returns
true if left decimal is smaller or equal than right; false otherwise.
Note
Please note this method works only if both decimal have same exponent
bool B2bits::Decimal::operator== ( Decimal const &  val) const

Compares two decimals.

Returns
true if two decimals are equal; false otherwise.
bool B2bits::Decimal::operator> ( Decimal const &  val) const

Compares two decimals.

Returns
true if left decimal is larger than right; false otherwise.
bool B2bits::Decimal::operator>= ( Decimal const &  val) const
inline

Compares two decimals.

Returns
true if left decimal is larger or equal than right; false otherwise.
double B2bits::Decimal::toDouble ( ) const

Converts stored value to double

Returns
double representation of the value
float B2bits::Decimal::toFloat ( ) const

Converts stored value to float

Returns
float representation of the value
std::string B2bits::Decimal::toStdString ( ) const

Converts decimal to FIX string. Converts decimal to FIX string

Returns
FIX representation of the Decimal value
char* B2bits::Decimal::toString ( char *  buf) const

Converts decimal to FIX string

Parameters
[out]bufBuffer to convert to. Should be enough to store Decimal::ValueSize bytes.
Returns
Pointer to the first character of the value
char* B2bits::Decimal::toString ( char *  buf,
std::size_t  size 
) const

If result string is less than passed buffer, remain chars will be filled with zeros according to FIX protocol.

Parameters
[out]bufBuffer to convert to.
[in]sizeSize of the buffer. Must be positive.

Member Data Documentation

unsigned int const B2bits::Decimal::ValueSize = 2 + 63 + sizeof( "18446744073709551616" )
static

Maximum buffer size required to store value.