Encapsulates float type.
More...
#include <b2bits/types/Decimal.h>
|
static unsigned int const | ValueSize = 2 + 63 + sizeof( "18446744073709551616" ) |
| Maximum buffer size required to store value. More...
|
|
B2bits::Decimal::Decimal |
( |
| ) |
|
|
inline |
B2bits::Decimal::Decimal |
( |
i64 |
m, |
|
|
i32 |
e |
|
) |
| |
|
inline |
Contructor Constructs object from mantissa and exponent
- Parameters
-
B2bits::Decimal::Decimal |
( |
double |
v | ) |
|
|
noexcept |
Contructor Constructs object from double
- Parameters
-
v | Value of the double type |
B2bits::Decimal::Decimal |
( |
i64 |
x | ) |
|
|
noexcept |
Contructor Constructs object from 64-bit integer
- Parameters
-
Decimal B2bits::Decimal::changeExponent |
( |
i32 |
newExponent | ) |
const |
Returns new Decimal value with required exponent.
- Parameters
-
newExponent | Required exponent. Must be in range [currentExponent-18 .. currentExponent+18] |
bool B2bits::Decimal::equals |
( |
const Decimal & |
rv | ) |
const |
Compares two Decimals
- Parameters
-
- 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
-
v | Value of the double type |
precision | Number 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
-
v | Value of the double type |
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.
Multiplication assignment.
Addition operator
- Note
- Please note this method works only if both decimal have same exponent
Decimal& B2bits::Decimal::operator++ |
( |
| ) |
|
|
inlinenoexcept |
Decimal B2bits::Decimal::operator++ |
( |
int |
| ) |
|
|
inlinenoexcept |
Addition assignment
- Note
- Please note this method works only if both decimal have same exponent
Substraction operator
- Note
- Please note this method works only if both decimal have same exponent
Decimal& B2bits::Decimal::operator-- |
( |
| ) |
|
|
inlinenoexcept |
Decimal B2bits::Decimal::operator-- |
( |
int |
| ) |
|
|
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
-
- 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] | buf | Buffer to convert to. |
[in] | size | Size of the buffer. Must be positive. |
unsigned int const B2bits::Decimal::ValueSize = 2 + 63 + sizeof( "18446744073709551616" ) |
|
static |
Maximum buffer size required to store value.