1#ifndef _KNOW_CORE_BIGNUMBER_H_
2#define _KNOW_CORE_BIGNUMBER_H_
5#include "ReturnValue.h"
7#include <Cyqlops/Crypto/Hash.h>
14 struct is_floating_point<knowCore::
BigNumber> :
public true_type
18 struct is_signed<knowCore::
BigNumber> :
public true_type
22 struct is_unsigned<knowCore::
BigNumber> :
public false_type
26 struct is_integral<knowCore::
BigNumber> :
public false_type
63 template<
typename _T_, std::enable_if_t<std::is_
integral_v<_T_> and std::is_
unsigned_v<_T_>,
int> = 0>
65 template<
typename _T_, std::enable_if_t<std::is_
integral_v<_T_> and std::is_
signed_v<_T_>,
int> = 0>
77 bool isFinite()
const;
78 bool isInfinite()
const;
83 QString toString()
const;
96 double toDouble()
const;
104 bool operator==(
const BigNumber& _rhs)
const;
105 bool operator!=(
const BigNumber& _rhs)
const {
return not (*
this == _rhs); }
106 QByteArray md5()
const;
110 void hash(QCryptographicHash* _hash)
const;
117 bool operator<(
const BigNumber& _rhs)
const;
118 bool operator<=(
const BigNumber& _rhs)
const;
119 bool operator>(
const BigNumber& _rhs)
const;
120 bool operator>=(
const BigNumber& _rhs)
const;
122 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
124 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
126 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
128 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
130 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
131 bool operator<(
const _T_& _rhs)
const {
return operator<(
BigNumber(_rhs)); }
132 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
133 bool operator<=(
const _T_& _rhs)
const {
return operator<=(
BigNumber(_rhs)); }
134 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
135 bool operator>(
const _T_& _rhs)
const {
return operator>(
BigNumber(_rhs)); }
136 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
137 bool operator>=(
const _T_& _rhs)
const {
return operator>=(
BigNumber(_rhs)); }
140 quint16 weight()
const {
return m_weight; }
141 Sign sign()
const {
return m_sign; }
142 quint16 dscale()
const {
return m_dscale; }
147 void exponenfy(
int exp);
150 enum class ComparisonResult { Bigger , Smaller , Equal };
151 ComparisonResult compare_abs(
const BigNumber& _rhs)
const;
152 ComparisonResult compare(
const BigNumber& _rhs)
const;
156 std::tuple<bool, quint64> toUInt64_ignore_sign()
const;
157 template<
typename _T_>
158 _T_ toVariantValue()
const;
160 qint16 m_weight, m_dscale;
164 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
166 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
168 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
170 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
172 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
173 static inline bool operator<(
const _T_& _lhs,
const BigNumber& _rhs) {
return BigNumber(_lhs) < _rhs; }
174 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
175 static inline bool operator<=(
const _T_& _lhs,
const BigNumber& _rhs) {
return BigNumber(_lhs) <= _rhs; }
176 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
177 static inline bool operator>(
const _T_& _lhs,
const BigNumber& _rhs) {
return BigNumber(_lhs) > _rhs; }
178 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
179 static inline bool operator>=(
const _T_& _lhs,
const BigNumber& _rhs) {
return BigNumber(_lhs) >= _rhs; }
180 template<
typename _T_, std::enable_if_t<std::is_arithmetic_v<_T_>,
bool> = true>
181 static inline bool operator==(
const _T_& _lhs,
const BigNumber& _rhs) {
return BigNumber(_lhs) == _rhs; }
185KNOWCORE_DECLARE_FULL_METATYPE(knowCore,
BigNumber)
187#include "Formatter.h"
191 return forward(p.toString(), ctx);
194namespace Cyqlops::Crypto::Hash
201 _v.
hash(&_algorithm);
Class that can contains large numeric value.
Definition BigNumber.h:46
bool isFloating() const
Definition BigNumber.cpp:224
void hash(QCryptographicHash *_hash) const
Definition BigNumber.cpp:517
ReturnValue< qint64 > toInt64(bool _truncate=false) const
Definition BigNumber.cpp:267
knowCore::Value toValue() const
return an optimal value representation This function try to return a variant with an optimal represen...
Definition BigNumber.cpp:498
QVariant toVariant() const
return an optimal variant representation This function try to return a variant with an optimal repres...
Definition BigNumber.cpp:493
Definition ReturnValue.h:29