Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
sw::universal::einteger< BlockType > Class Template Reference

#include <einteger_impl.hpp>

Public Types

using bt = BlockType

Public Member Functions

constexpr einteger () noexcept
constexpr einteger (const einteger &)=default
constexpr einteger (einteger &&)=default
constexpr einteger & operator= (const einteger &)=default
constexpr einteger & operator= (einteger &&)=default
 einteger (short initial_value)
 einteger (int initial_value)
 einteger (long initial_value)
 einteger (long long initial_value)
 einteger (unsigned int initial_value)
 einteger (unsigned long initial_value)
 einteger (unsigned long long initial_value)
 einteger (float initial_value)
 einteger (double initial_value)
einteger & operator= (int rhs) noexcept
einteger & operator= (long rhs) noexcept
einteger & operator= (long long rhs) noexcept
einteger & operator= (unsigned int rhs) noexcept
einteger & operator= (unsigned long rhs) noexcept
einteger & operator= (unsigned long long rhs) noexcept
einteger & operator= (float rhs) noexcept
einteger & operator= (double rhs) noexcept
 operator int () const noexcept
 operator long () const noexcept
 operator long long () const noexcept
 operator float () const noexcept
 operator double () const noexcept
einteger & operator<<= (int shift)
einteger & operator>>= (int shift)
einteger operator- () const
einteger operator++ (int)
einteger & operator++ ()
einteger operator-- (int)
einteger & operator-- ()
einteger & operator+= (const einteger &rhs)
einteger & operator+= (long long rhs)
einteger & operator-= (const einteger &rhs)
einteger & operator-= (long long rhs)
einteger & operator*= (const einteger &rhs)
einteger & operator*= (long long rhs)
einteger & operator/= (const einteger &rhs)
einteger & operator/= (long long rhs)
einteger & operator%= (const einteger &rhs)
einteger & operator%= (long long rhs)
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & operator+= (Real rhs)
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & operator-= (Real rhs)
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & operator*= (Real rhs)
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & operator/= (Real rhs)
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & operator%= (Real rhs)
void reduce (const einteger &a, const einteger &b, einteger &r)
constexpr void clear () noexcept
constexpr void setzero () noexcept
constexpr void setsign (bool sign=true) noexcept
void setbits (unsigned long long value)
void setblock (unsigned i, BlockType value) noexcept
void setbyte (unsigned i, std::uint8_t byte) noexcept
einteger & assign (const std::string &txt)
constexpr bool iszero () const noexcept
constexpr bool isone () const noexcept
constexpr bool isodd () const noexcept
constexpr bool iseven () const noexcept
constexpr bool ispos () const noexcept
constexpr bool isneg () const noexcept
constexpr bool test (unsigned index) const noexcept
constexpr bool sign () const noexcept
constexpr int scale () const noexcept
constexpr BlockType block (unsigned b) const noexcept
constexpr unsigned limbs () const noexcept
constexpr unsigned nbits () const noexcept
constexpr int findMsb () const noexcept
std::string str (size_t nrDigits=0) const
std::string showLimbs () const
std::string showLimbValues () const

Static Public Attributes

static constexpr unsigned bitsInBlock = sizeof(BlockType) * 8
static constexpr bt ALL_ONES = bt(0xFFFF'FFFF'FFFF'FFFFull)
static constexpr uint64_t BASE = uint64_t(ALL_ONES) + 1ull

Protected Member Functions

int compare_magnitude (const einteger &a, const einteger &b)
void remove_leading_zeros ()
template<typename SignedInt>
einteger & convert_signed (SignedInt v)
template<typename UnsignedInt>
einteger & convert_unsigned (UnsignedInt v)
template<typename Real>
einteger & convert_ieee754 (Real &rhs)
template<typename Integer>
Integer convert_to_native_integer () const noexcept
template<typename Real>
Real convert_to_native_ieee () const noexcept

Protected Attributes

bool _sign
std::vector< BlockType > _block

Friends

template<typename BBlockType>
constexpr bool operator== (const einteger< BBlockType > &, const einteger< BBlockType > &) noexcept
template<typename BBlockType>
bool parse (const std::string &, einteger< BBlockType > &)

Member Typedef Documentation

◆ bt

template<typename BlockType = std::uint32_t>
using sw::universal::einteger< BlockType >::bt = BlockType

Constructor & Destructor Documentation

◆ einteger() [1/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( )
inlineconstexprnoexcept

◆ einteger() [2/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( const einteger< BlockType > & )
constexprdefault

◆ einteger() [3/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( einteger< BlockType > && )
constexprdefault

◆ einteger() [4/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( short initial_value)
inline

◆ einteger() [5/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( int initial_value)
inline

◆ einteger() [6/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( long initial_value)
inline

◆ einteger() [7/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( long long initial_value)
inline

◆ einteger() [8/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( unsigned int initial_value)
inline

◆ einteger() [9/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( unsigned long initial_value)
inline

◆ einteger() [10/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( unsigned long long initial_value)
inline

◆ einteger() [11/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( float initial_value)
inline

◆ einteger() [12/12]

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::einteger ( double initial_value)
inline

Member Function Documentation

◆ assign()

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::assign ( const std::string & txt)
inline

◆ block()

template<typename BlockType = std::uint32_t>
BlockType sw::universal::einteger< BlockType >::block ( unsigned b) const
inlineconstexprnoexcept

◆ clear()

template<typename BlockType = std::uint32_t>
void sw::universal::einteger< BlockType >::clear ( )
inlineconstexprnoexcept

◆ compare_magnitude()

template<typename BlockType = std::uint32_t>
int sw::universal::einteger< BlockType >::compare_magnitude ( const einteger< BlockType > & a,
const einteger< BlockType > & b )
inlineprotected

◆ convert_ieee754()

template<typename BlockType = std::uint32_t>
template<typename Real>
einteger & sw::universal::einteger< BlockType >::convert_ieee754 ( Real & rhs)
inlineprotected

◆ convert_signed()

template<typename BlockType = std::uint32_t>
template<typename SignedInt>
einteger & sw::universal::einteger< BlockType >::convert_signed ( SignedInt v)
inlineprotected

◆ convert_to_native_ieee()

template<typename BlockType = std::uint32_t>
template<typename Real>
Real sw::universal::einteger< BlockType >::convert_to_native_ieee ( ) const
inlineprotectednoexcept

◆ convert_to_native_integer()

template<typename BlockType = std::uint32_t>
template<typename Integer>
Integer sw::universal::einteger< BlockType >::convert_to_native_integer ( ) const
inlineprotectednoexcept

◆ convert_unsigned()

template<typename BlockType = std::uint32_t>
template<typename UnsignedInt>
einteger & sw::universal::einteger< BlockType >::convert_unsigned ( UnsignedInt v)
inlineprotected

◆ findMsb()

template<typename BlockType = std::uint32_t>
int sw::universal::einteger< BlockType >::findMsb ( ) const
inlineconstexprnoexcept

◆ iseven()

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::iseven ( ) const
inlineconstexprnoexcept

◆ isneg()

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::isneg ( ) const
inlineconstexprnoexcept

◆ isodd()

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::isodd ( ) const
inlineconstexprnoexcept

◆ isone()

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::isone ( ) const
inlineconstexprnoexcept

◆ ispos()

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::ispos ( ) const
inlineconstexprnoexcept

◆ iszero()

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::iszero ( ) const
inlineconstexprnoexcept

◆ limbs()

template<typename BlockType = std::uint32_t>
unsigned sw::universal::einteger< BlockType >::limbs ( ) const
inlineconstexprnoexcept

◆ nbits()

template<typename BlockType = std::uint32_t>
unsigned sw::universal::einteger< BlockType >::nbits ( ) const
inlineconstexprnoexcept

◆ operator double()

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::operator double ( ) const
inlineexplicitnoexcept

◆ operator float()

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::operator float ( ) const
inlineexplicitnoexcept

◆ operator int()

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::operator int ( ) const
inlineexplicitnoexcept

◆ operator long()

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::operator long ( ) const
inlineexplicitnoexcept

◆ operator long long()

template<typename BlockType = std::uint32_t>
sw::universal::einteger< BlockType >::operator long long ( ) const
inlineexplicitnoexcept

◆ operator%=() [1/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator%= ( const einteger< BlockType > & rhs)
inline

◆ operator%=() [2/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator%= ( long long rhs)
inline

◆ operator%=() [3/3]

template<typename BlockType = std::uint32_t>
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & sw::universal::einteger< BlockType >::operator%= ( Real rhs)
inline

◆ operator*=() [1/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator*= ( const einteger< BlockType > & rhs)
inline

◆ operator*=() [2/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator*= ( long long rhs)
inline

◆ operator*=() [3/3]

template<typename BlockType = std::uint32_t>
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & sw::universal::einteger< BlockType >::operator*= ( Real rhs)
inline

◆ operator++() [1/2]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator++ ( )
inline

◆ operator++() [2/2]

template<typename BlockType = std::uint32_t>
einteger sw::universal::einteger< BlockType >::operator++ ( int )
inline

◆ operator+=() [1/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator+= ( const einteger< BlockType > & rhs)
inline

◆ operator+=() [2/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator+= ( long long rhs)
inline

◆ operator+=() [3/3]

template<typename BlockType = std::uint32_t>
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & sw::universal::einteger< BlockType >::operator+= ( Real rhs)
inline

◆ operator-()

template<typename BlockType = std::uint32_t>
einteger sw::universal::einteger< BlockType >::operator- ( ) const
inline

◆ operator--() [1/2]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator-- ( )
inline

◆ operator--() [2/2]

template<typename BlockType = std::uint32_t>
einteger sw::universal::einteger< BlockType >::operator-- ( int )
inline

◆ operator-=() [1/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator-= ( const einteger< BlockType > & rhs)
inline

◆ operator-=() [2/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator-= ( long long rhs)
inline

◆ operator-=() [3/3]

template<typename BlockType = std::uint32_t>
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & sw::universal::einteger< BlockType >::operator-= ( Real rhs)
inline

◆ operator/=() [1/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator/= ( const einteger< BlockType > & rhs)
inline

◆ operator/=() [2/3]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator/= ( long long rhs)
inline

◆ operator/=() [3/3]

template<typename BlockType = std::uint32_t>
template<typename Real, std::enable_if_t< std::is_floating_point_v< Real >, int > = 0>
einteger & sw::universal::einteger< BlockType >::operator/= ( Real rhs)
inline

◆ operator<<=()

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator<<= ( int shift)
inline

◆ operator=() [1/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( const einteger< BlockType > & )
constexprdefault

◆ operator=() [2/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( double rhs)
inlinenoexcept

◆ operator=() [3/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( einteger< BlockType > && )
constexprdefault

◆ operator=() [4/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( float rhs)
inlinenoexcept

◆ operator=() [5/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( int rhs)
inlinenoexcept

◆ operator=() [6/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( long long rhs)
inlinenoexcept

◆ operator=() [7/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( long rhs)
inlinenoexcept

◆ operator=() [8/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( unsigned int rhs)
inlinenoexcept

◆ operator=() [9/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( unsigned long long rhs)
inlinenoexcept

◆ operator=() [10/10]

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator= ( unsigned long rhs)
inlinenoexcept

◆ operator>>=()

template<typename BlockType = std::uint32_t>
einteger & sw::universal::einteger< BlockType >::operator>>= ( int shift)
inline

◆ reduce()

template<typename BlockType = std::uint32_t>
void sw::universal::einteger< BlockType >::reduce ( const einteger< BlockType > & a,
const einteger< BlockType > & b,
einteger< BlockType > & r )
inline

◆ remove_leading_zeros()

template<typename BlockType = std::uint32_t>
void sw::universal::einteger< BlockType >::remove_leading_zeros ( )
inlineprotected

◆ scale()

template<typename BlockType = std::uint32_t>
int sw::universal::einteger< BlockType >::scale ( ) const
inlineconstexprnoexcept

◆ setbits()

template<typename BlockType = std::uint32_t>
void sw::universal::einteger< BlockType >::setbits ( unsigned long long value)
inline

◆ setblock()

template<typename BlockType = std::uint32_t>
void sw::universal::einteger< BlockType >::setblock ( unsigned i,
BlockType value )
inlinenoexcept

◆ setbyte()

template<typename BlockType = std::uint32_t>
void sw::universal::einteger< BlockType >::setbyte ( unsigned i,
std::uint8_t byte )
inlinenoexcept

◆ setsign()

template<typename BlockType = std::uint32_t>
void sw::universal::einteger< BlockType >::setsign ( bool sign = true)
inlineconstexprnoexcept

◆ setzero()

template<typename BlockType = std::uint32_t>
void sw::universal::einteger< BlockType >::setzero ( )
inlineconstexprnoexcept

◆ showLimbs()

template<typename BlockType>
std::string sw::universal::einteger< BlockType >::showLimbs ( ) const

◆ showLimbValues()

template<typename BlockType>
std::string sw::universal::einteger< BlockType >::showLimbValues ( ) const

◆ sign()

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::sign ( ) const
inlineconstexprnoexcept

◆ str()

template<typename BlockType = std::uint32_t>
std::string sw::universal::einteger< BlockType >::str ( size_t nrDigits = 0) const
inline

◆ test()

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::test ( unsigned index) const
inlineconstexprnoexcept

◆ operator==

template<typename BlockType = std::uint32_t>
template<typename BBlockType>
bool operator== ( const einteger< BBlockType > & ,
const einteger< BBlockType > &  )
friend

◆ parse

template<typename BlockType = std::uint32_t>
template<typename BBlockType>
bool parse ( const std::string & ,
einteger< BBlockType > &  )
friend

Member Data Documentation

◆ _block

template<typename BlockType = std::uint32_t>
std::vector<BlockType> sw::universal::einteger< BlockType >::_block
protected

◆ _sign

template<typename BlockType = std::uint32_t>
bool sw::universal::einteger< BlockType >::_sign
protected

◆ ALL_ONES

template<typename BlockType = std::uint32_t>
bt sw::universal::einteger< BlockType >::ALL_ONES = bt(0xFFFF'FFFF'FFFF'FFFFull)
staticconstexpr

◆ BASE

template<typename BlockType = std::uint32_t>
uint64_t sw::universal::einteger< BlockType >::BASE = uint64_t(ALL_ONES) + 1ull
staticconstexpr

◆ bitsInBlock

template<typename BlockType = std::uint32_t>
unsigned sw::universal::einteger< BlockType >::bitsInBlock = sizeof(BlockType) * 8
staticconstexpr

The documentation for this class was generated from the following files:
  • /home/runner/work/universal/universal/include/sw/universal/number/einteger/einteger_fwd.hpp
  • /home/runner/work/universal/universal/include/sw/universal/number/einteger/einteger_impl.hpp
  • /home/runner/work/universal/universal/include/sw/universal/number/einteger/debug.hpp