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

#include <MRMesh/MRFastInt.h>

Public Member Functions

 FastInt () noexcept=default
template<typename T>
requires detail::cFitsFastInt128<T>
constexpr FastInt (T v) noexcept
 sign-extends the given value, which must fit in 128 bits
template<int mBits>
requires ( mBits < nBits )
constexpr FastInt (const FastInt< mBits > &v) noexcept
 sign-extends a narrower value of this family
template<int mBits>
requires ( mBits > nBits )
constexpr FastInt (const FastInt< mBits > &v) noexcept
constexpr int sign () const noexcept
 -1, 0 or 1 if the value is negative, zero or positive respectively
constexpr FastIntoperator+= (const FastInt &b) noexcept
constexpr FastIntoperator-= (const FastInt &b) noexcept
constexpr FastInt operator- () const noexcept

Public Attributes

std::array< std::uint64_t, numWordsw = {}
 two's complement representation: w[0] + 2^64 * w[1] + ... + 2^(nBits-64) * std::int64_t( w[numWords-1] )

Static Public Attributes

static constexpr int numWords = nBits / 64
 the number of words in the representation below

Friends

constexpr FastInt operator+ (FastInt a, const FastInt &b) noexcept
constexpr FastInt operator- (FastInt a, const FastInt &b) noexcept
constexpr bool operator== (const FastInt &a, const FastInt &b) noexcept
constexpr std::strong_ordering operator<=> (const FastInt &a, const FastInt &b) noexcept

Detailed Description

template<int nBits>
class MR::FastInt< nBits >

signed integer of nBits bits, which must be a multiple of 64 and at least 192 (below that use FastInt128 with Int64Mul128 and Int128Mul256); the product of two of them is exact, because it is twice as wide as the arguments; as FastInt128 it lacks a sqrt-function and stream input/output

Constructor & Destructor Documentation

◆ FastInt() [1/4]

template<int nBits>
MR::FastInt< nBits >::FastInt ( )
defaultnoexcept

◆ FastInt() [2/4]

template<int nBits>
template<typename T>
requires detail::cFitsFastInt128<T>
MR::FastInt< nBits >::FastInt ( T v)
inlineconstexprnoexcept

sign-extends the given value, which must fit in 128 bits

◆ FastInt() [3/4]

template<int nBits>
template<int mBits>
requires ( mBits < nBits )
MR::FastInt< nBits >::FastInt ( const FastInt< mBits > & v)
inlineconstexprnoexcept

sign-extends a narrower value of this family

◆ FastInt() [4/4]

template<int nBits>
template<int mBits>
requires ( mBits > nBits )
MR::FastInt< nBits >::FastInt ( const FastInt< mBits > & v)
inlineexplicitconstexprnoexcept

takes the lowest nBits bits of a wider value of this family, which must be enough to represent it exactly; as every product below widens, this is how a value with a proven bound returns to the narrow type where it belongs

the value does not fit in nBits bits

Member Function Documentation

◆ operator+=()

template<int nBits>
FastInt & MR::FastInt< nBits >::operator+= ( const FastInt< nBits > & b)
inlineconstexprnoexcept

◆ operator-()

template<int nBits>
FastInt MR::FastInt< nBits >::operator- ( ) const
inlinenodiscardconstexprnoexcept

◆ operator-=()

template<int nBits>
FastInt & MR::FastInt< nBits >::operator-= ( const FastInt< nBits > & b)
inlineconstexprnoexcept

◆ sign()

template<int nBits>
int MR::FastInt< nBits >::sign ( ) const
inlinenodiscardconstexprnoexcept

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

◆ operator+

template<int nBits>
FastInt operator+ ( FastInt< nBits > a,
const FastInt< nBits > & b )
friend

◆ operator-

template<int nBits>
FastInt operator- ( FastInt< nBits > a,
const FastInt< nBits > & b )
friend

◆ operator<=>

template<int nBits>
std::strong_ordering operator<=> ( const FastInt< nBits > & a,
const FastInt< nBits > & b )
friend

◆ operator==

template<int nBits>
bool operator== ( const FastInt< nBits > & a,
const FastInt< nBits > & b )
friend

Member Data Documentation

◆ numWords

template<int nBits>
int MR::FastInt< nBits >::numWords = nBits / 64
staticconstexpr

the number of words in the representation below

◆ w

template<int nBits>
std::array<std::uint64_t, numWords> MR::FastInt< nBits >::w = {}

two's complement representation: w[0] + 2^64 * w[1] + ... + 2^(nBits-64) * std::int64_t( w[numWords-1] )


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