#include <MRMesh/MRVarBigInt.h>
Public Member Functions | |
| VarBigInt () noexcept=default | |
| VarBigInt (const VarBigInt &o) | |
| Buffer is move-only, so the copy of the heap-backed alternative is done by hand. | |
| VarBigInt (VarBigInt &&) noexcept=default | |
| VarBigInt & | operator= (const VarBigInt &o) |
| VarBigInt & | operator= (VarBigInt &&) noexcept=default |
| VarBigInt (std::int64_t v) | |
| VarBigInt (FastInt128 v) | |
| from a 128-bit integer (explicit to keep int -> VarBigInt unambiguous via the int64 ctor) | |
| template<int nBits> | |
| VarBigInt (const FastInt< nBits > &v) | |
| int | sign () const noexcept |
| -1, 0 or 1 if the value is negative, zero or positive respectively | |
| VarBigInt | operator- () const |
| VarBigInt & | operator+= (const VarBigInt &b) |
| VarBigInt & | operator-= (const VarBigInt &b) |
Friends | |
| VarBigInt | operator+ (const VarBigInt &a, const VarBigInt &b) |
| VarBigInt | operator- (const VarBigInt &a, const VarBigInt &b) |
| VarBigInt | operator* (const VarBigInt &a, const VarBigInt &b) |
| bool | operator== (const VarBigInt &a, const VarBigInt &b) noexcept |
| std::strong_ordering | operator<=> (const VarBigInt &a, const VarBigInt &b) noexcept |
a minimal variable-length signed big integer in sign-magnitude form over base-2^64 limbs, a lightweight replacement for boost::multiprecision::cpp_int in the exact predicates; it implements only what the simulation-of-simplicity inSphere tie resolution needs: construction from machine integers and from fixed-precision FastInt<N> / FastInt128, addition, subtraction, multiplication, sign, and comparison. There is deliberately no division and no square root: signOf() in MRInSphere.cpp only multiplies, compares and reads the sign. Unlike FastInt<N> the width grows with the value, so no per-sub-expression bit-width bounds are needed.
The magnitude limbs live in a std::variant of two same-size-excluding-heap options: a heap-backed Buffer<uint64_t> for really long integers, and an inline std::array<uint64_t,2> giving small-value optimization (values up to 128 bits, e.g. every value in the tiny near-degenerate regime, are stored without touching the heap).
|
defaultnoexcept |
|
inline |
Buffer is move-only, so the copy of the heap-backed alternative is done by hand.
|
defaultnoexcept |
|
inline |
from a signed machine integer; non-explicit so that mixed expressions like 2 * x or x + n keep reading naturally, exactly as they did with boost cpp_int
magnitude of v as unsigned two's-complement negation, correct also for INT64_MIN
|
inlineexplicit |
from a 128-bit integer (explicit to keep int -> VarBigInt unambiguous via the int64 ctor)
|
inlineexplicit |
from a fixed-precision integer of the FastInt family; mirrors toBoostInt(): takes the magnitude of the two's-complement words so 2^nBits is never needed
two's-complement words, little-endian
|
inlinenodiscard |
|
inlinenodiscardnoexcept |
-1, 0 or 1 if the value is negative, zero or positive respectively
opposite signs, equal magnitudes => zero
by magnitude
flip for negatives