MeshLib C++ Docs
Loading...
Searching...
No Matches

#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
VarBigIntoperator= (const VarBigInt &o)
VarBigIntoperator= (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
VarBigIntoperator+= (const VarBigInt &b)
VarBigIntoperator-= (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

Detailed Description

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).

Constructor & Destructor Documentation

◆ VarBigInt() [1/6]

MR::VarBigInt::VarBigInt ( )
defaultnoexcept

◆ VarBigInt() [2/6]

MR::VarBigInt::VarBigInt ( const VarBigInt & o)
inline

Buffer is move-only, so the copy of the heap-backed alternative is done by hand.

◆ VarBigInt() [3/6]

MR::VarBigInt::VarBigInt ( VarBigInt && )
defaultnoexcept

◆ VarBigInt() [4/6]

MR::VarBigInt::VarBigInt ( std::int64_t v)
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

◆ VarBigInt() [5/6]

MR::VarBigInt::VarBigInt ( FastInt128 v)
inlineexplicit

from a 128-bit integer (explicit to keep int -> VarBigInt unambiguous via the int64 ctor)

◆ VarBigInt() [6/6]

template<int nBits>
MR::VarBigInt::VarBigInt ( const FastInt< nBits > & v)
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

Member Function Documentation

◆ operator+=()

VarBigInt & MR::VarBigInt::operator+= ( const VarBigInt & b)
inline

◆ operator-()

VarBigInt MR::VarBigInt::operator- ( ) const
inlinenodiscard

◆ operator-=()

VarBigInt & MR::VarBigInt::operator-= ( const VarBigInt & b)
inline

◆ operator=() [1/2]

VarBigInt & MR::VarBigInt::operator= ( const VarBigInt & o)
inline

◆ operator=() [2/2]

VarBigInt & MR::VarBigInt::operator= ( VarBigInt && )
defaultnoexcept

◆ sign()

int MR::VarBigInt::sign ( ) const
inlinenodiscardnoexcept

-1, 0 or 1 if the value is negative, zero or positive respectively

◆ operator*

VarBigInt operator* ( const VarBigInt & a,
const VarBigInt & b )
friend

◆ operator+

VarBigInt operator+ ( const VarBigInt & a,
const VarBigInt & b )
friend

opposite signs, equal magnitudes => zero

◆ operator-

VarBigInt operator- ( const VarBigInt & a,
const VarBigInt & b )
friend

◆ operator<=>

std::strong_ordering operator<=> ( const VarBigInt & a,
const VarBigInt & b )
friend

by magnitude

flip for negatives

◆ operator==

bool operator== ( const VarBigInt & a,
const VarBigInt & b )
friend

The documentation for this class was generated from the following file: