Template Class NativeIntegerT
Defined in File ubintnat.h
Page Contents
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public lbcrypto::BigIntegerInterface< NativeIntegerT< NativeInt > >
(Template Class BigIntegerInterface)
Template Parameter Order
typename NativeInt
Class Documentation
-
template<typename NativeInt>
class intnat::NativeIntegerT : public lbcrypto::BigIntegerInterface<NativeIntegerT<NativeInt>> Inheritence diagram for intnat::NativeIntegerT:
Collaboration diagram for intnat::NativeIntegerT:
Main class for big integers represented as an array of native (primitive) unsigned integers.
- Template Parameters
NativeInt – native unsigned integer type
Public Types
Public Functions
-
inline explicit operator bool() const
-
constexpr NativeIntegerT() = default
-
inline constexpr NativeIntegerT(const NativeIntegerT &val) noexcept
-
inline constexpr NativeIntegerT(NativeIntegerT &&val) noexcept
-
inline NativeIntegerT(const std::string &val)
-
inline explicit NativeIntegerT(const char *strval)
-
template<typename T, std::enable_if_t<std::is_integral_v<T> || std::is_same_v<T, int128_t> || std::is_same_v<T, uint128_t>, bool> = true>
inline constexpr NativeIntegerT(T val) noexcept
-
template<typename T, std::enable_if_t<std::is_same_v<T, M2Integer> || std::is_same_v<T, M4Integer> || std::is_same_v<T, M6Integer>, bool> = true>
inline constexpr NativeIntegerT(T val) noexcept
-
template<typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
NativeIntegerT(T val) = delete
-
inline constexpr NativeIntegerT &operator=(const NativeIntegerT &val) noexcept
-
inline constexpr NativeIntegerT &operator=(NativeIntegerT &&val) noexcept
-
inline NativeIntegerT &operator=(const std::string &val)
-
inline NativeIntegerT &operator=(const char *strval)
-
template<typename T, std::enable_if_t<std::is_integral_v<T> || std::is_same_v<T, int128_t> || std::is_same_v<T, uint128_t>, bool> = true>
inline constexpr NativeIntegerT &operator=(T val) noexcept
-
template<typename T, std::enable_if_t<std::is_same_v<T, M2Integer> || std::is_same_v<T, M4Integer> || std::is_same_v<T, M6Integer>, bool> = true>
inline constexpr NativeIntegerT &operator=(T val) noexcept
-
template<typename T, std::enable_if_t<std::is_floating_point_v<T>, bool> = true>
NativeIntegerT &operator=(T val) = delete
-
inline void SetValue(const std::string &str)
Basic set method for setting the value of a native integer
- Parameters
&strval – is the string representation of the native integer to be copied.
-
inline void SetValue(const NativeIntegerT &val)
Basic set method for setting the value of a native integer
- Parameters
&val – is the big binary integer representation of the native integer to be assigned.
-
inline void SetIdentity()
Set this int to 1.
-
inline NativeIntegerT Add(const NativeIntegerT &b) const
Addition operation.
- Parameters
&b – is the value to add.
- Returns
result of the addition operation.
-
inline NativeIntegerT AddCheck(const NativeIntegerT &b) const
AddCheck is the addition operation with bounds checking.
- Parameters
b – is the value to add to this.
- Returns
result of the addition operation.
-
inline NativeIntegerT AddFast(const NativeIntegerT &b) const
AddFast is the addition operation without bounds checking.
- Parameters
b – is the value to add to this.
- Returns
result of the addition operation.
-
inline NativeIntegerT &AddEq(const NativeIntegerT &b)
Addition operation. In-place variant.
- Parameters
&b – is the value to add.
- Returns
result of the addition operation.
-
inline NativeIntegerT &AddEqCheck(const NativeIntegerT &b)
AddEqCheck is the addition in place operation with bounds checking. In-place variant.
- Parameters
b – is the value to add to this.
- Returns
result of the addition operation.
-
inline NativeIntegerT &AddEqFast(const NativeIntegerT &b)
AddEqFast is the addition in place operation without bounds checking. In-place variant.
- Parameters
b – is the value to add to this.
- Returns
result of the addition operation.
-
inline NativeIntegerT Sub(const NativeIntegerT &b) const
Subtraction operation.
- Parameters
&b – is the value to subtract.
- Returns
is the result of the subtraction operation.
-
inline NativeIntegerT SubCheck(const NativeIntegerT &b) const
SubCheck is the subtraction operation with bounds checking.
- Parameters
b – is the value to add to this.
- Returns
result of the addition operation.
-
inline NativeIntegerT SubFast(const NativeIntegerT &b) const
SubFast is the subtraction operation without bounds checking.
- Parameters
b – is the value to add to this.
- Returns
result of the addition operation.
-
inline NativeIntegerT &SubEq(const NativeIntegerT &b)
Subtraction operation. In-place variant.
- Parameters
&b – is the value to subtract.
- Returns
is the result of the subtraction operation.
-
inline NativeIntegerT &SubEqCheck(const NativeIntegerT &b)
SubEqCheck is the subtraction in place operation with bounds checking. In-place variant.
- Parameters
b – is the value to add to this.
- Returns
result of the addition operation.
-
inline NativeIntegerT &SubEqFast(const NativeIntegerT &b)
SubEqFast is the subtraction in place operation without bounds checking. In-place variant.
- Parameters
b – is the value to add to this.
- Returns
result of the addition operation.
-
inline NativeIntegerT operator-() const
-
inline NativeIntegerT Mul(const NativeIntegerT &b) const
Multiplication operation.
- Parameters
&b – is the value to multiply with.
- Returns
is the result of the multiplication operation.
-
inline NativeIntegerT MulCheck(const NativeIntegerT &b) const
MulCheck is the multiplication operation with bounds checking.
- Parameters
b – is the value to multiply with
- Returns
result of the multiplication operation
-
inline NativeIntegerT MulFast(const NativeIntegerT &b) const
MulFast is the multiplication operation without bounds checking.
- Parameters
b – is the value to multiply with.
- Returns
result of the multiplication operation.
-
inline NativeIntegerT &MulEq(const NativeIntegerT &b)
Multiplication operation. In-place variant.
- Parameters
&b – is the value to multiply with.
- Returns
is the result of the multiplication operation.
-
inline NativeIntegerT &MulEqCheck(const NativeIntegerT &b)
MulEqCheck is the multiplication in place operation with bounds checking. In-place variant.
- Parameters
b – is the value to multiply with
- Returns
result of the multiplication operation
-
inline NativeIntegerT &MulEqFast(const NativeIntegerT &b)
MulEqFast is the multiplication in place operation without bounds checking. In-place variant.
- Parameters
b – is the value to multiply with
- Returns
result of the multiplication operation
-
inline NativeIntegerT DividedBy(const NativeIntegerT &b) const
Division operation.
- Parameters
&b – is the value to divide by.
- Returns
is the result of the division operation.
-
inline NativeIntegerT &DividedByEq(const NativeIntegerT &b)
Division operation. In-place variant.
- Parameters
&b – is the value to divide by.
- Returns
is the result of the division operation.
-
inline NativeIntegerT Exp(usint p) const
Exponentiation operation. Returns x^p.
- Parameters
p – the exponent.
- Returns
is the result of the exponentiation operation.
-
inline NativeIntegerT &ExpEq(usint p)
Exponentiation operation. Returns x^p. In-place variant.
- Parameters
p – the exponent.
- Returns
is the result of the exponentiation operation.
-
inline NativeIntegerT MultiplyAndRound(const NativeIntegerT &p, const NativeIntegerT &q) const
Multiply and Rounding operation. Returns [x*p/q] where [] is the rounding operation.
- Parameters
&p – is the numerator to be multiplied.
&q – is the denominator to be divided.
- Returns
is the result of multiply and round operation.
-
inline NativeIntegerT &MultiplyAndRoundEq(const NativeIntegerT &p, const NativeIntegerT &q)
Multiply and Rounding operation. Returns [x*p/q] where [] is the rounding operation. In-place variant.
- Parameters
&p – is the numerator to be multiplied.
&q – is the denominator to be divided.
- Returns
is the result of multiply and round operation.
-
inline NativeIntegerT DivideAndRound(const NativeIntegerT &q) const
Computes the quotient of x*p/q, where x,p,q are all NativeInt numbers, x is the current value; uses DNativeInt arithmetic
- Parameters
p – is the multiplicand
q – is the divisor
p – is the multiplicand
q – is the divisor
&q – is the denominator to be divided.
- Returns
the quotient Computes the remainder of x*p/q, where x,p,q are all NativeInt numbers, x is the current value; uses DNativeInt arithmetic. In-place variant.
- Returns
the remainder Divide and Rounding operation. Returns [x/q] where [] is the rounding operation.
- Returns
is the result of divide and round operation.
-
inline NativeIntegerT &DivideAndRoundEq(const NativeIntegerT &q)
Divide and Rounding operation. Returns [x/q] where [] is the rounding operation. In-place variant.
- Parameters
&q – is the denominator to be divided.
- Returns
is the result of divide and round operation.
-
inline NativeIntegerT Mod(const NativeIntegerT &modulus) const
Naive modulus operation.
- Parameters
&modulus – is the modulus to perform.
- Returns
is the result of the modulus operation.
-
inline NativeIntegerT &ModEq(const NativeIntegerT &modulus)
Naive modulus operation. In-place variant.
- Parameters
&modulus – is the modulus to perform.
- Returns
is the result of the modulus operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ComputeMu(typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) const Precomputes a parameter mu for Barrett modular reduction.
- Returns
the precomputed parameter mu.
-
template<typename T = NativeInt>
inline NativeIntegerT ComputeMu(typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true) const
-
inline NativeIntegerT Mod(const NativeIntegerT &modulus, const NativeIntegerT &mu) const
Barrett modulus operation. Implements generalized Barrett modular reduction algorithm. Uses one precomputed value of mu.
- Parameters
&modulus – is the modulus to perform.
&mu – is the Barrett value.
- Returns
is the result of the modulus operation.
-
inline NativeIntegerT &ModEq(const NativeIntegerT &modulus, const NativeIntegerT &mu)
Barrett modulus operation. In-place variant. Implements generalized Barrett modular reduction algorithm. Uses one precomputed value of mu.
- Parameters
&modulus – is the modulus to perform.
&mu – is the Barrett value.
- Returns
is the result of the modulus operation.
-
inline NativeIntegerT ModAdd(const NativeIntegerT &b, const NativeIntegerT &modulus) const
Modulus addition operation.
- Parameters
&b – is the scalar to add.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus addition operation.
-
inline NativeIntegerT &ModAddEq(const NativeIntegerT &b, const NativeIntegerT &modulus)
Modulus addition operation. In-place variant.
- Parameters
&b – is the scalar to add.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus addition operation.
-
inline NativeIntegerT ModAddFast(const NativeIntegerT &b, const NativeIntegerT &modulus) const
Modulus addition where operands are < modulus.
- Parameters
&b – is the scalar to add.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus addition operation.
-
inline NativeIntegerT &ModAddFastEq(const NativeIntegerT &b, const NativeIntegerT &modulus)
Modulus addition where operands are < modulus. In-place variant.
- Parameters
&b – is the scalar to add.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus addition operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModAdd(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) const Barrett modulus addition operation.
- Parameters
&b – is the scalar to add.
&modulus – is the modulus to perform operations with.
&mu – is the Barrett value.
- Returns
is the result of the modulus addition operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModAdd(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true) const
-
template<typename T = NativeInt>
inline NativeIntegerT &ModAddEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) Barrett modulus addition operation. In-place variant.
- Parameters
&b – is the scalar to add.
&modulus – is the modulus to perform operations with.
&mu – is the Barrett value.
- Returns
is the result of the modulus addition operation.
-
template<typename T = NativeInt>
inline NativeIntegerT &ModAddEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true)
-
inline NativeIntegerT ModSub(const NativeIntegerT &b, const NativeIntegerT &modulus) const
Modulus subtraction operation.
- Parameters
&b – is the scalar to subtract.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus subtraction operation.
-
inline NativeIntegerT &ModSubEq(const NativeIntegerT &b, const NativeIntegerT &modulus)
Modulus subtraction operation. In-place variant.
- Parameters
&b – is the scalar to subtract.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus subtraction operation.
-
inline NativeIntegerT ModSubFast(const NativeIntegerT &b, const NativeIntegerT &modulus) const
Modulus subtraction where operands are < modulus.
- Parameters
&b – is the scalar to subtract.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus subtraction operation.
-
inline NativeIntegerT &ModSubFastEq(const NativeIntegerT &b, const NativeIntegerT &modulus)
Modulus subtraction where operands are < modulus. In-place variant.
- Parameters
&b – is the scalar to subtract.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus subtraction operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModSub(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) const Barrett modulus subtraction operation.
- Parameters
&b – is the scalar to subtract.
&modulus – is the modulus to perform operations with.
&mu – is the Barrett value.
- Returns
is the result of the modulus subtraction operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModSub(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true) const
-
template<typename T = NativeInt>
inline NativeIntegerT &ModSubEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true)
-
template<typename T = NativeInt>
inline NativeIntegerT &ModSubEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true)
-
template<typename T = NativeInt>
inline NativeIntegerT ModMul(const NativeIntegerT &b, const NativeIntegerT &modulus, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) const Modulus multiplication operation.
- Parameters
&b – is the scalar to multiply.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModMul(const NativeIntegerT &b, const NativeIntegerT &modulus, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true) const
-
template<typename T = NativeInt>
inline NativeIntegerT &ModMulEq(const NativeIntegerT &b, const NativeIntegerT &modulus, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) Modulus multiplication operation. In-place variant.
- Parameters
&b – is the scalar to multiply.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT &ModMulEq(const NativeIntegerT &b, const NativeIntegerT &modulus, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true)
-
template<typename T = NativeInt>
inline NativeIntegerT ModMul(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) const Barrett modulus multiplication.
- Parameters
&b – is the scalar to multiply.
&modulus – is the modulus to perform operations with.
&mu – is the Barrett value.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModMul(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true) const
-
template<typename T = NativeInt>
inline NativeIntegerT &ModMulEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) Barrett modulus multiplication. In-place variant.
- Parameters
&b – is the scalar to multiply.
&modulus – is the modulus to perform operations with.
&mu – is the Barrett value.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT &ModMulEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true)
-
template<typename T = NativeInt>
inline NativeIntegerT ModMulFast(const NativeIntegerT &b, const NativeIntegerT &modulus, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) const Modulus multiplication that assumes the operands are < modulus.
- Parameters
&b – is the scalar to multiply.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModMulFast(const NativeIntegerT &b, const NativeIntegerT &modulus, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true) const
-
template<typename T = NativeInt>
inline NativeIntegerT ModMulFastEq(const NativeIntegerT &b, const NativeIntegerT &modulus, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) Modulus multiplication that assumes the operands are < modulus. In-place variant.
- Parameters
&b – is the scalar to multiply.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModMulFastEq(const NativeIntegerT &b, const NativeIntegerT &modulus, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true)
-
template<typename T = NativeInt>
inline NativeIntegerT ModMulFast(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) const Barrett modulus multiplication that assumes the operands are < modulus.
- Parameters
&b – is the scalar to multiply.
&modulus – is the modulus to perform operations with.
&mu – is the Barrett value.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModMulFast(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true) const
-
template<typename T = NativeInt>
inline NativeIntegerT &ModMulFastEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<!std::is_same_v<T, DNativeInt>, bool> = true) Barrett modulus multiplication that assumes the operands are < modulus. In-place variant.
- Parameters
&b – is the scalar to multiply.
&modulus – is the modulus to perform operations with.
&mu – is the Barrett value.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT &ModMulFastEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &mu, typename std::enable_if_t<std::is_same_v<T, DNativeInt>, bool> = true)
-
template<typename T = NativeInt>
inline NativeIntegerT PrepModMulConst(const NativeIntegerT &modulus, typename std::enable_if<!std::is_same<T, DNativeInt>::value, bool>::type = true) const Precomputation for a multiplicand.
- Parameters
modulus – is the modulus to perform operations with.
- Returns
the precomputed factor.
-
template<typename T = NativeInt>
inline NativeIntegerT PrepModMulConst(const NativeIntegerT &modulus, typename std::enable_if<std::is_same<T, DNativeInt>::value, bool>::type = true) const
-
inline NativeIntegerT ModMulFastConst(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &bInv) const
Modular multiplication using a precomputation for the multiplicand.
- Parameters
&b – is the NativeIntegerT to multiply.
modulus – is the modulus to perform operations with.
&bInv – precomputation for b.
- Returns
is the result of the modulus multiplication operation.
-
inline NativeIntegerT &ModMulFastConstEq(const NativeIntegerT &b, const NativeIntegerT &modulus, const NativeIntegerT &bInv)
Modular multiplication using a precomputation for the multiplicand. In-place variant.
- Parameters
&b – is the NativeIntegerT to multiply.
modulus – is the modulus to perform operations with.
&bInv – precomputation for b.
- Returns
is the result of the modulus multiplication operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModExp(const NativeIntegerT &b, const NativeIntegerT &mod, typename std::enable_if<!std::is_same<T, DNativeInt>::value, bool>::type = true) const Modulus exponentiation operation.
- Parameters
&b – is the scalar to exponentiate at all locations.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus exponentiation operation.
-
template<typename T = NativeInt>
inline NativeIntegerT ModExp(const NativeIntegerT &b, const NativeIntegerT &mod, typename std::enable_if<std::is_same<T, DNativeInt>::value, bool>::type = true) const
-
inline NativeIntegerT &ModExpEq(const NativeIntegerT &b, const NativeIntegerT &mod)
Modulus exponentiation operation. In-place variant.
- Parameters
&b – is the scalar to exponentiate at all locations.
&modulus – is the modulus to perform operations with.
- Returns
is the result of the modulus exponentiation operation.
-
inline NativeIntegerT ModInverse(const NativeIntegerT &mod) const
Modulus inverse operation.
- Parameters
&modulus – is the modulus to perform.
- Returns
is the result of the modulus inverse operation.
-
inline NativeIntegerT &ModInverseEq(const NativeIntegerT &mod)
Modulus inverse operation. In-place variant.
- Parameters
&modulus – is the modulus to perform.
- Returns
is the result of the modulus inverse operation.
-
inline NativeIntegerT LShift(usshort shift) const
Left shift operation.
- Parameters
shift – # of bits.
- Returns
result of the shift operation.
-
inline NativeIntegerT &LShiftEq(usshort shift)
Left shift operation. In-place variant.
- Parameters
shift – # of bits.
- Returns
result of the shift operation.
-
inline NativeIntegerT RShift(usshort shift) const
Right shift operation.
- Parameters
shift – # of bits.
- Returns
result of the shift operation.
-
inline NativeIntegerT &RShiftEq(usshort shift)
Right shift operation. In-place variant.
- Parameters
shift – # of bits.
- Returns
result of the shift operation.
-
inline int Compare(const NativeIntegerT &a) const
Compares the current NativeIntegerT to NativeIntegerT a.
- Parameters
a – is the NativeIntegerT to be compared with.
- Returns
-1 for strictly less than, 0 for equal to and 1 for strictly greater than conditons.
-
template<typename T = NativeInt, std::enable_if_t<std::is_integral_v<T> || std::is_same_v<T, int128_t> || std::is_same_v<T, uint128_t>, bool> = true>
inline constexpr T ConvertToInt() const noexcept Converts the value to an int.
- Returns
the int representation of the value as usint.
-
inline constexpr double ConvertToDouble() const noexcept
Converts the value to an double.
- Returns
double representation of the value.
-
inline usint GetMSB() const
Returns the MSB location of the value.
- Returns
the index of the most significant bit.
-
inline usint GetLengthForBase(usint base) const
Get the number of digits using a specific base - support for arbitrary base may be needed.
- Parameters
base – is the base with which to determine length in.
- Returns
the length of the representation in a specific base.
-
inline usint GetDigitAtIndexForBase(usint index, usint base) const
Get a specific digit at “digit” index; big integer is seen as an array of digits, where a 0 <= digit < base Warning: only power-of-2 bases are currently supported. Example: for number 83, index 2 and base 4 we have:
83 —base 4 decomposition–> (3,0,1,1) —at index 2–> 1index:0,1,2,3
The return number is 1.
- Parameters
index – is the “digit” index of the requested digit
base – is the base with which to determine length in.
- Returns
is the requested digit
-
inline uschar GetBitAtIndex(usint index) const
Gets the bit at the specified index.
- Parameters
index – is the index of the bit to get.
- Returns
resulting bit.
-
inline std::string ToString() const
Stores the based 10 equivalent/Decimal value of the NativeIntegerT in a string object and returns it.
- Returns
value of this NativeIntegerT in base 10 represented as a string.
-
template<class Archive, typename T = void>
inline std::enable_if_t<std::is_same_v<NativeInt, uint64_t> || std::is_same_v<NativeInt, uint32_t>, T> load(Archive &ar, std::uint32_t const version)
-
template<class Archive, typename T = void>
inline std::enable_if_t<std::is_same_v<NativeInt, uint64_t> || std::is_same<NativeInt, uint32_t>::value, T> save(Archive &ar, std::uint32_t const version) const
-
inline std::string SerializedObjectName() const
Public Static Functions
-
static inline NativeIntegerT FromBinaryString(const std::string &bitString)
Convert a string representation of a binary number to a NativeIntegerT.
- Parameters
bitString – the binary num in string.
- Returns
the binary number represented as a big binary int.
-
static inline constexpr NativeIntegerT Allocator() noexcept
A zero allocator that is called by the Matrix class. It is used to initialize a Matrix of NativeIntegerT objects.
-
static inline const std::string IntegerTypeName()
-
static inline uint32_t SerializedVersion()
-
static inline constexpr bool IsNativeInt() noexcept
Friends
-
inline friend std::ostream &operator<<(std::ostream &os, const NativeIntegerT &ptr_obj)
Console output operation.
- Parameters
os – is the std ostream object.
ptr_obj – is NativeIntegerT to be printed.
- Returns
is the ostream object.