LongPort OpenAPI C++ SDK
|
#include <decimal.hpp>
Public Member Functions | |
Decimal (const lb_decimal_t *other) | |
Decimal (const Decimal &other) | |
Decimal (const char *str) | |
Constructs a new Decimal number from string. More... | |
Decimal (const std::string &str) | |
Constructs a new Decimal number from string. More... | |
Decimal (double other) | |
Constructs a new Decimal number from double. More... | |
Decimal (double other, uint32_t dp) | |
~Decimal () | |
operator const lb_decimal_t * () const | |
operator lb_decimal_t * () | |
operator double () const | |
Decimal | operator+ (const Decimal &other) const |
Decimal & | operator+= (const Decimal &other) |
Decimal | operator- (const Decimal &other) const |
Decimal & | operator-= (const Decimal &other) |
Decimal | operator* (const Decimal &other) const |
Decimal & | operator*= (const Decimal &other) |
Decimal | operator/ (const Decimal &other) const |
Decimal & | operator/= (const Decimal &other) |
Decimal | operator% (const Decimal &other) const |
Decimal & | operator%= (const Decimal &other) |
Decimal | operator- () const |
bool | operator> (const Decimal &other) const |
bool | operator>= (const Decimal &other) const |
bool | operator== (const Decimal &other) const |
bool | operator< (const Decimal &other) const |
bool | operator<= (const Decimal &other) const |
double | to_double () const |
void | abs () |
Computes the absolute value. More... | |
void | ceil () |
Returns the smallest integer greater than or equal to a number. More... | |
void | floor () |
Returns the largest integer less than or equal to a number. More... | |
void | fract () |
Returns a new Decimal representing the fractional portion of the number. More... | |
bool | is_negative () const |
Returns true if the decimal is negative. More... | |
bool | is_positive () const |
Returns true if the decimal is positive. More... | |
bool | is_zero () const |
Returns true if this Decimal number is equivalent to zero. More... | |
Decimal | max (const Decimal &other) const |
Returns the maximum of the two numbers. More... | |
Decimal | min (const Decimal &other) const |
Returns the minimum of the two numbers. More... | |
void | normalize () |
Strips any trailing zero’s from a Decimal and converts -0 to 0 . More... | |
void | round () |
void | round (uint32_t dp) |
void | trunc () |
void | sin () |
Computes the sine of a number (in radians) More... | |
void | cos () |
Computes the cosine of a number (in radians) More... | |
void | tan () |
void | sqrt () |
The square root of a Decimal. Uses a standard Babylonian method. More... | |
void | pow (const Decimal &exp) |
void | ln () |
void | log10 () |
Calculates the base 10 logarithm of a specified Decimal number. More... | |
void | exp () |
void | exp_with_tolerance (const Decimal &tolerance) |
void | erf () |
void | norm_pdf () |
The Probability density function for a Normal distribution. More... | |
std::string | to_string () const |
longport::Decimal::Decimal | ( | const lb_decimal_t * | other | ) |
longport::Decimal::Decimal | ( | const Decimal & | other | ) |
longport::Decimal::Decimal | ( | const char * | str | ) |
Constructs a new Decimal number from string.
longport::Decimal::Decimal | ( | const std::string & | str | ) |
Constructs a new Decimal number from string.
longport::Decimal::Decimal | ( | double | other | ) |
Constructs a new Decimal number from double.
longport::Decimal::Decimal | ( | double | other, |
uint32_t | dp | ||
) |
Constructs a new Decimal number with the specified number of decimal points for fractional portion. Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8
longport::Decimal::~Decimal | ( | ) |
void longport::Decimal::abs | ( | ) |
Computes the absolute value.
void longport::Decimal::ceil | ( | ) |
Returns the smallest integer greater than or equal to a number.
void longport::Decimal::cos | ( | ) |
Computes the cosine of a number (in radians)
void longport::Decimal::erf | ( | ) |
Abramowitz Approximation of Error Function from wikipedia
void longport::Decimal::exp | ( | ) |
The estimated exponential function, ex. Stops calculating when it is within tolerance of roughly 0.0000002
.
void longport::Decimal::exp_with_tolerance | ( | const Decimal & | tolerance | ) |
The estimated exponential function, ex using the tolerance
provided as a hint as to when to stop calculating. A larger tolerance will cause the number to stop calculating sooner at the potential cost of a slightly less accurate result.
void longport::Decimal::floor | ( | ) |
Returns the largest integer less than or equal to a number.
void longport::Decimal::fract | ( | ) |
Returns a new Decimal representing the fractional portion of the number.
bool longport::Decimal::is_negative | ( | ) | const |
Returns true
if the decimal is negative.
bool longport::Decimal::is_positive | ( | ) | const |
Returns true
if the decimal is positive.
bool longport::Decimal::is_zero | ( | ) | const |
Returns true
if this Decimal number is equivalent to zero.
void longport::Decimal::ln | ( | ) |
Calculates the natural logarithm for a Decimal calculated using Taylor’s series.
void longport::Decimal::log10 | ( | ) |
Calculates the base 10 logarithm of a specified Decimal number.
Returns the maximum of the two numbers.
Returns the minimum of the two numbers.
void longport::Decimal::norm_pdf | ( | ) |
The Probability density function for a Normal distribution.
void longport::Decimal::normalize | ( | ) |
Strips any trailing zero’s from a Decimal and converts -0
to 0
.
longport::Decimal::operator const lb_decimal_t * | ( | ) | const |
longport::Decimal::operator double | ( | ) | const |
longport::Decimal::operator lb_decimal_t * | ( | ) |
Decimal longport::Decimal::operator- | ( | ) | const |
bool longport::Decimal::operator< | ( | const Decimal & | other | ) | const |
bool longport::Decimal::operator<= | ( | const Decimal & | other | ) | const |
bool longport::Decimal::operator== | ( | const Decimal & | other | ) | const |
bool longport::Decimal::operator> | ( | const Decimal & | other | ) | const |
bool longport::Decimal::operator>= | ( | const Decimal & | other | ) | const |
void longport::Decimal::pow | ( | const Decimal & | exp | ) |
Raise self to the given Decimal exponent: xy. If exp
is not whole then the approximation ey*ln(x) is used.
void longport::Decimal::round | ( | ) |
Returns a new Decimal number with no fractional portion (i.e. an integer). Rounding currently follows “Bankers Rounding” rules. e.g. 6.5
-> 6
, 7.5
-> 8
void longport::Decimal::round | ( | uint32_t | dp | ) |
Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding currently follows “Bankers Rounding” rules. e.g. 6.5 -> 6, 7.5 -> 8
void longport::Decimal::sin | ( | ) |
Computes the sine of a number (in radians)
void longport::Decimal::sqrt | ( | ) |
The square root of a Decimal. Uses a standard Babylonian method.
void longport::Decimal::tan | ( | ) |
Computes the tangent of a number (in radians). Panics upon overflow or upon approaching a limit.
double longport::Decimal::to_double | ( | ) | const |
std::string longport::Decimal::to_string | ( | ) | const |
void longport::Decimal::trunc | ( | ) |
Returns a new Decimal integral with no fractional portion. This is a true truncation whereby no rounding is performed.