kDB: Knowledge DataBase
|
Class that can contains large numeric value. More...
#include <BigNumber.h>
Public Types | |
enum class | Sign { Positive , Negative , NaN , PositiveInfinite , NegativeInfinite } |
Public Member Functions | |
BigNumber (const BigNumber &_rhs) | |
BigNumber (BigNumber &&_rhs) | |
BigNumber & | operator= (const BigNumber &_rhs) |
BigNumber (qint16 weight, Sign sign, qint16 dscale, const QList< quint16 > &digits) | |
BigNumber (std::intmax_t _value) | |
BigNumber (std::uintmax_t _value) | |
template<typename _T_ > requires (std::is_integral_v<_T_> and std::is_unsigned_v<_T_>) | |
BigNumber (_T_ _value) | |
template<typename _T_ > requires (std::is_integral_v<_T_> and std::is_signed_v<_T_>) | |
BigNumber (_T_ _value) | |
BigNumber (double _value) | |
bool | isNaN () const |
bool | isFinite () const |
bool | isInfinite () const |
bool | isFloating () const |
QString | toString () const |
QVariant | toVariant () const |
return an optimal variant representation This function try to return a variant with an optimal representation: | |
knowCore::Value | toValue () const |
return an optimal value representation This function try to return a variant with an optimal representation: | |
double | toDouble () const |
cres_qresult< qint64 > | toInt64 (bool _truncate=false) const |
cres_qresult< quint64 > | toUInt64 (bool _truncate=false) const |
bool | operator== (const BigNumber &_rhs) const |
bool | operator!= (const BigNumber &_rhs) const |
QByteArray | md5 () const |
void | hash (QCryptographicHash *_hash) const |
BigNumber | operator+ (const BigNumber &_rhs) const |
BigNumber | operator- (const BigNumber &_rhs) const |
BigNumber | operator* (const BigNumber &_rhs) const |
BigNumber | operator/ (const BigNumber &_rhs) const |
BigNumber | operator- () const |
bool | operator< (const BigNumber &_rhs) const |
bool | operator<= (const BigNumber &_rhs) const |
bool | operator> (const BigNumber &_rhs) const |
bool | operator>= (const BigNumber &_rhs) const |
template<typename _T_ > requires (std::is_arithmetic_v<_T_>) | |
BigNumber | operator+ (const _T_ &_rhs) const |
template<typename _T_ > requires (std::is_arithmetic_v<_T_>) | |
BigNumber | operator- (const _T_ &_rhs) const |
template<typename _T_ > requires (std::is_arithmetic_v<_T_>) | |
BigNumber | operator* (const _T_ &_rhs) const |
template<typename _T_ > requires (std::is_arithmetic_v<_T_>) | |
BigNumber | operator/ (const _T_ &_rhs) const |
template<typename _T_ > requires (std::is_arithmetic_v<_T_>) | |
bool | operator< (const _T_ &_rhs) const |
template<typename _T_ > requires (std::is_arithmetic_v<_T_>) | |
bool | operator<= (const _T_ &_rhs) const |
template<typename _T_ > requires (std::is_arithmetic_v<_T_>) | |
bool | operator> (const _T_ &_rhs) const |
template<typename _T_ > requires (std::is_arithmetic_v<_T_>) | |
bool | operator>= (const _T_ &_rhs) const |
quint16 | weight () const |
Sign | sign () const |
quint16 | dscale () const |
QList< quint16 > | digits () const |
Static Public Member Functions | |
static cres_qresult< BigNumber > | fromString (const QString &_value) |
static cres_qresult< BigNumber > | fromString (const char *_value) |
static cres_qresult< BigNumber > | fromVariant (const QVariant &_value) |
static cres_qresult< BigNumber > | fromValue (const knowCore::Value &_value) |
static BigNumber | zero () |
static BigNumber | nan () |
static BigNumber | positiveInfinite () |
static BigNumber | negativeInfinite () |
Class that can contains large numeric value.
The representation of number in this class is modeled after the one used by postgres (see postgres/src/backend/utils/adt/numeric.c source code for the "specification").
In BigNumber the number are stored in base-1000:
The number is given by m_digits[0]*10000^m_weight + m_digits[1]*10000^(m_weight-1) + ....
void BigNumber::hash | ( | QCryptographicHash * | _hash | ) | const |
Add the big number to a cryptographic hash calculation.
bool BigNumber::isFloating | ( | ) | const |
cres_qresult< qint64 > BigNumber::toInt64 | ( | bool | _truncate = false | ) | const |
Attempt to convert to int64, in case of overflow, return an error.
_truncate
if set to true truncate a floating point number, otherwise return an error if big number is a floating point
Value BigNumber::toValue | ( | ) | const |
return an optimal value representation This function try to return a variant with an optimal representation:
QVariant BigNumber::toVariant | ( | ) | const |
return an optimal variant representation This function try to return a variant with an optimal representation: