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::areal< _nbits, _es, bt > Class Template Reference

An arbitrary configuration real number with gradual under/overflow and uncertainty bit. More...

#include <areal_impl.hpp>

Public Types

using BlockType = bt

Public Member Functions

constexpr areal () noexcept
constexpr areal (const areal &) noexcept=default
constexpr areal (areal &&) noexcept=default
constexpr areal & operator= (const areal &) noexcept=default
constexpr areal & operator= (areal &&) noexcept=default
template<unsigned nnbits, unsigned ees>
 areal (const areal< nnbits, ees, bt > &rhs)
 construct an areal from another configuration with the same block type.
constexpr areal (const SpecificValue code)
constexpr areal (signed char iv) noexcept
 construct an areal from a native type, specialized for size
constexpr areal (short iv) noexcept
constexpr areal (int iv) noexcept
constexpr areal (long iv) noexcept
constexpr areal (long long iv) noexcept
constexpr areal (char iv) noexcept
constexpr areal (unsigned short iv) noexcept
constexpr areal (unsigned int iv) noexcept
constexpr areal (unsigned long iv) noexcept
constexpr areal (unsigned long long iv) noexcept
constexpr areal (float iv) noexcept
constexpr areal (double iv) noexcept
constexpr areal (long double iv) noexcept
constexpr areal & operator= (signed char rhs)
constexpr areal & operator= (short rhs)
constexpr areal & operator= (int rhs)
constexpr areal & operator= (long rhs)
constexpr areal & operator= (long long rhs)
constexpr areal & operator= (char rhs)
constexpr areal & operator= (unsigned short rhs)
constexpr areal & operator= (unsigned int rhs)
constexpr areal & operator= (unsigned long rhs)
constexpr areal & operator= (unsigned long long rhs)
template<typename Ty>
constexpr areal & convert_unsigned_integer (const Ty &rhs) noexcept
template<typename Ty>
constexpr areal & convert_signed_integer (const Ty &rhs) noexcept
CONSTEXPRESSION areal & operator= (float rhs)
CONSTEXPRESSION areal & operator= (double rhs)
CONSTEXPRESSION areal & operator= (long double rhs)
constexpr areal operator- () const noexcept
constexpr areal & operator+= (const areal &rhs)
constexpr areal & operator+= (double rhs)
constexpr areal & operator-= (const areal &rhs)
constexpr areal & operator-= (double rhs)
constexpr areal & operator*= (const areal &rhs)
constexpr areal & operator*= (double rhs)
constexpr areal & operator/= (const areal &rhs)
constexpr areal & operator/= (double rhs)
constexpr areal & operator++ ()
 move to the next bit encoding modulo 2^nbits
constexpr areal operator++ (int)
constexpr areal & operator-- ()
 move to the previous bit encoding modulo 2^nbits (the symmetric inverse of operator++).
constexpr areal operator-- (int)
constexpr void clear () noexcept
 clear the content of this areal to zero
constexpr void setzero () noexcept
 set the number to +0
constexpr void setsign (bool sign=true) noexcept
 set the sign bit of the areal
constexpr void setinf (bool sign=true) noexcept
 set the number to +inf
constexpr void setnan (int NaNType=NAN_TYPE_SIGNALLING) noexcept
 set the number to a quiet NaN (+nan) or a signalling NaN (-nan, default)
constexpr areal< nbits, es, bt > & maxpos () noexcept
constexpr areal< nbits, es, bt > & minpos () noexcept
constexpr areal< nbits, es, bt > & zero () noexcept
constexpr areal< nbits, es, bt > & minneg () noexcept
constexpr areal< nbits, es, bt > & maxneg () noexcept
constexpr void saturate_reserved () noexcept
constexpr areal & setbits (uint64_t raw_bits) noexcept
 set the raw bits of the areal.
constexpr void set (unsigned i, bool v=true) noexcept
 set a specific bit in the encoding to true or false.
constexpr void reset (unsigned i) noexcept
 reset a specific bit in the encoding to false.
constexpr areal & flip () noexcept
 1's complement of the encoding
areal & assign (const std::string &stringRep)
 assign the value of a text representation to the areal: a decimal, the exact form [d], or the uncertain form (d, dnext) that operator<< writes.
constexpr bool sign () const noexcept
constexpr bool ubit () const noexcept
constexpr int scale () const
constexpr bool isneg () const
constexpr bool ispos () const
constexpr bool iszero () const
constexpr bool isone () const
constexpr bool isinf (int InfType=INF_TYPE_EITHER) const
 check if value is infinite, -inf, or +inf.
constexpr bool isnormal_ () const noexcept
 check if the value is a normal number (exponent is not all 0s or all 1s) Note: named with underscore suffix to avoid conflict with std::isnormal
constexpr bool issubnormal_ () const noexcept
 check if the value is a subnormal number (exponent is all 0s but value is not zero) Note: named with underscore suffix to avoid conflict with std::issubnormal
constexpr bool isnan (int NaNType=NAN_TYPE_EITHER) const
 check if a value is a quiet or a signalling NaN quiet NaN = 0-1111-11111-1: sign = 0, uncertainty = 1, es/fraction bits = 1 signalling NaN = 1-1111-11111-1: sign = 1, uncertainty = 1, es/fraction bits = 1
constexpr bool test (unsigned bitIndex) const noexcept
constexpr bool at (unsigned bitIndex) const noexcept
constexpr uint8_t nibble (unsigned n) const noexcept
constexpr bt block (unsigned b) const noexcept
void constexprClassParameters () const
constexpr void exponent (blockbinary< es, bt > &e) const
constexpr void fraction (blockbinary< fbits, bt > &f) const
constexpr uint64_t fraction_ull () const noexcept
long to_long () const
long long to_long_long () const
template<typename TargetFloat>
TargetFloat to_native () const
 operator int () const noexcept
 operator long long () const noexcept
 operator long double () const noexcept
 operator double () const noexcept
 operator float () const noexcept
constexpr void normalizeAddition (blocktriple< fbits, BlockTripleOperator::ADD, bt > &tgt) const
constexpr void normalizeMultiplication (blocktriple< fbits, BlockTripleOperator::MUL, bt > &tgt) const
constexpr void normalizeDivision (blocktriple< fbits, BlockTripleOperator::DIV, bt > &tgt) const

Static Public Attributes

static constexpr unsigned bitsInByte = 8ull
static constexpr unsigned bitsInBlock = sizeof(bt) * bitsInByte
static constexpr unsigned nbits = _nbits
static constexpr unsigned es = _es
static constexpr unsigned fbits = nbits - 2ull - es
static constexpr unsigned fhbits = fbits + 1ull
static constexpr unsigned abits = fhbits + 3ull
static constexpr unsigned mbits = 2ull * fhbits
static constexpr unsigned divbits = 3ull * fhbits + 4ull
static constexpr unsigned nrBlocks = 1ull + ((nbits - 1ull) / bitsInBlock)
static constexpr uint64_t storageMask = (0xFFFFFFFFFFFFFFFFull >> (64ull - bitsInBlock))
static constexpr unsigned MSU = nrBlocks - 1ull
static constexpr bt ALLONES = bt(~0)
static constexpr bt MSU_MASK = (ALLONES >> (nrBlocks * bitsInBlock - nbits))
static constexpr unsigned bitsInMSU = bitsInBlock - (nrBlocks * bitsInBlock - nbits)
static constexpr bt SIGN_BIT_MASK = bt(bt(1ull) << ((nbits - 1ull) % bitsInBlock))
static constexpr bt LSB_BIT_MASK = bt(1ull)
static constexpr bool MSU_CAPTURES_E = (1ull + es) <= bitsInMSU
static constexpr unsigned EXP_SHIFT = (MSU_CAPTURES_E ? (1 == nrBlocks ? (nbits - 1ull - es) : (bitsInMSU - 1ull - es)) : 0)
static constexpr bt MSU_EXP_MASK = ((ALLONES << EXP_SHIFT) & ~SIGN_BIT_MASK) & MSU_MASK
static constexpr int EXP_BIAS = ((1l << (es - 1ull)) - 1l)
static constexpr int MAX_EXP = (1l << es) - 1l - EXP_BIAS
static constexpr int MIN_EXP_NORMAL = 1 - EXP_BIAS
static constexpr int MIN_EXP_SUBNORMAL = 1 - EXP_BIAS - int(fbits)
static constexpr bt BLOCK_MASK = bt(-1)

Protected Member Functions

CONSTEXPRESSION areal & assign_extended (long double rhs)
template<unsigned srcbits, typename StorageType>
constexpr uint64_t round (StorageType raw, int &exponent) noexcept
 round a set of source bits to the present representation.
template<typename ArgumentBlockType>
constexpr void copyBits (ArgumentBlockType v)
void shiftLeft (int bitsToShift)
void shiftRight (int bitsToShift)

Friends

template<unsigned nnbits, unsigned nes, typename nbt>
std::ostream & operator<< (std::ostream &ostr, const areal< nnbits, nes, nbt > &r)
template<unsigned nnbits, unsigned nes, typename nbt>
constexpr bool operator== (const areal< nnbits, nes, nbt > &lhs, const areal< nnbits, nes, nbt > &rhs)
template<unsigned nnbits, unsigned nes, typename nbt>
constexpr bool operator!= (const areal< nnbits, nes, nbt > &lhs, const areal< nnbits, nes, nbt > &rhs)
template<unsigned nnbits, unsigned nes, typename nbt>
constexpr bool operator< (const areal< nnbits, nes, nbt > &lhs, const areal< nnbits, nes, nbt > &rhs)
template<unsigned nnbits, unsigned nes, typename nbt>
constexpr bool operator> (const areal< nnbits, nes, nbt > &lhs, const areal< nnbits, nes, nbt > &rhs)
template<unsigned nnbits, unsigned nes, typename nbt>
constexpr bool operator<= (const areal< nnbits, nes, nbt > &lhs, const areal< nnbits, nes, nbt > &rhs)
template<unsigned nnbits, unsigned nes, typename nbt>
constexpr bool operator>= (const areal< nnbits, nes, nbt > &lhs, const areal< nnbits, nes, nbt > &rhs)

Detailed Description

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
class sw::universal::areal< _nbits, _es, bt >

An arbitrary configuration real number with gradual under/overflow and uncertainty bit.

Template Parameters
nbitsnumber of bits in the encoding
esnumber of exponent bits in the encoding
btthe type to use as storage class: one of [uint8_t|uint16_t|uint32_t]

Member Typedef Documentation

◆ BlockType

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
using sw::universal::areal< _nbits, _es, bt >::BlockType = bt

Constructor & Destructor Documentation

◆ areal() [1/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( )
inlineconstexprnoexcept

◆ areal() [2/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( const areal< _nbits, _es, bt > & )
constexprdefaultnoexcept

◆ areal() [3/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( areal< _nbits, _es, bt > && )
constexprdefaultnoexcept

◆ areal() [4/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned nnbits, unsigned ees>
sw::universal::areal< _nbits, _es, bt >::areal ( const areal< nnbits, ees, bt > & rhs)
inline

construct an areal from another configuration with the same block type.

The value converts with the target's rounding, its ubit set when bits are dropped, and the source's ubit carries over: an inexact source stays inexact. The body was empty, so the target held whatever its storage held (#1970): areal<16,5>(areal<8,3>(1.5f)) was garbage.

Parameters
rhsthe source areal

◆ areal() [5/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( const SpecificValue code)
inlineconstexpr

◆ areal() [6/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( signed char iv)
inlineconstexprnoexcept

construct an areal from a native type, specialized for size

Parameters
ivinitial value to construct

◆ areal() [7/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( short iv)
inlineconstexprnoexcept

◆ areal() [8/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( int iv)
inlineconstexprnoexcept

◆ areal() [9/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( long iv)
inlineconstexprnoexcept

◆ areal() [10/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( long long iv)
inlineconstexprnoexcept

◆ areal() [11/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( char iv)
inlineconstexprnoexcept

◆ areal() [12/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( unsigned short iv)
inlineconstexprnoexcept

◆ areal() [13/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( unsigned int iv)
inlineconstexprnoexcept

◆ areal() [14/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( unsigned long iv)
inlineconstexprnoexcept

◆ areal() [15/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( unsigned long long iv)
inlineconstexprnoexcept

◆ areal() [16/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( float iv)
inlineconstexprnoexcept

◆ areal() [17/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( double iv)
inlineconstexprnoexcept

◆ areal() [18/18]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::areal ( long double iv)
inlineconstexprnoexcept

Member Function Documentation

◆ assign()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::assign ( const std::string & stringRep)
inline

assign the value of a text representation to the areal: a decimal, the exact form [d], or the uncertain form (d, dnext) that operator<< writes.

See parse().

Parameters
stringRepthe text to assign
Returns
reference to this areal; zero if the text does not parse, as dfloat and bfloat16 do

◆ assign_extended()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
CONSTEXPRESSION areal & sw::universal::areal< _nbits, _es, bt >::assign_extended ( long double rhs)
inlineprotected

◆ at()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::at ( unsigned bitIndex) const
inlineconstexprnoexcept

◆ block()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bt sw::universal::areal< _nbits, _es, bt >::block ( unsigned b) const
inlineconstexprnoexcept

◆ clear()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::clear ( )
inlineconstexprnoexcept

clear the content of this areal to zero

◆ constexprClassParameters()

template<unsigned nbits, unsigned es, typename bt>
void sw::universal::areal< nbits, es, bt >::constexprClassParameters ( ) const

◆ convert_signed_integer()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<typename Ty>
areal & sw::universal::areal< _nbits, _es, bt >::convert_signed_integer ( const Ty & rhs)
inlineconstexprnoexcept

◆ convert_unsigned_integer()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<typename Ty>
areal & sw::universal::areal< _nbits, _es, bt >::convert_unsigned_integer ( const Ty & rhs)
inlineconstexprnoexcept

◆ copyBits()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<typename ArgumentBlockType>
void sw::universal::areal< _nbits, _es, bt >::copyBits ( ArgumentBlockType v)
inlineconstexprprotected

◆ exponent()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::exponent ( blockbinary< es, bt > & e) const
inlineconstexpr

◆ flip()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::flip ( )
inlineconstexprnoexcept

1's complement of the encoding

Returns
reference to this areal object

◆ fraction()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::fraction ( blockbinary< fbits, bt > & f) const
inlineconstexpr

◆ fraction_ull()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
uint64_t sw::universal::areal< _nbits, _es, bt >::fraction_ull ( ) const
inlineconstexprnoexcept

◆ isinf()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::isinf ( int InfType = INF_TYPE_EITHER) const
inlineconstexpr

check if value is infinite, -inf, or +inf.

+inf = 0-1111-11111-0: sign = 0, uncertainty = 0, es/fraction bits = 1 -inf = 1-1111-11111-0: sign = 1, uncertainty = 0, es/fraction bits = 1

Parameters
InfTypedefault is 0, both types, -1 checks for -inf, 1 checks for +inf
Returns
true if +-inf, false otherwise

◆ isnan()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::isnan ( int NaNType = NAN_TYPE_EITHER) const
inlineconstexpr

check if a value is a quiet or a signalling NaN quiet NaN = 0-1111-11111-1: sign = 0, uncertainty = 1, es/fraction bits = 1 signalling NaN = 1-1111-11111-1: sign = 1, uncertainty = 1, es/fraction bits = 1

Parameters
NaNTypedefault is 0, both types, 1 checks for Signalling NaN, -1 checks for Quiet NaN
Returns
true if the right kind of NaN, false otherwise

◆ isneg()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::isneg ( ) const
inlineconstexpr

◆ isnormal_()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::isnormal_ ( ) const
inlineconstexprnoexcept

check if the value is a normal number (exponent is not all 0s or all 1s) Note: named with underscore suffix to avoid conflict with std::isnormal

Returns
true if normal, false otherwise

◆ isone()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::isone ( ) const
inlineconstexpr

◆ ispos()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::ispos ( ) const
inlineconstexpr

◆ issubnormal_()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::issubnormal_ ( ) const
inlineconstexprnoexcept

check if the value is a subnormal number (exponent is all 0s but value is not zero) Note: named with underscore suffix to avoid conflict with std::issubnormal

Returns
true if subnormal, false otherwise

◆ iszero()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::iszero ( ) const
inlineconstexpr

◆ maxneg()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal< nbits, es, bt > & sw::universal::areal< _nbits, _es, bt >::maxneg ( )
inlineconstexprnoexcept

◆ maxpos()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal< nbits, es, bt > & sw::universal::areal< _nbits, _es, bt >::maxpos ( )
inlineconstexprnoexcept

◆ minneg()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal< nbits, es, bt > & sw::universal::areal< _nbits, _es, bt >::minneg ( )
inlineconstexprnoexcept

◆ minpos()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal< nbits, es, bt > & sw::universal::areal< _nbits, _es, bt >::minpos ( )
inlineconstexprnoexcept

◆ nibble()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
uint8_t sw::universal::areal< _nbits, _es, bt >::nibble ( unsigned n) const
inlineconstexprnoexcept

◆ normalizeAddition()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::normalizeAddition ( blocktriple< fbits, BlockTripleOperator::ADD, bt > & tgt) const
inlineconstexpr

◆ normalizeDivision()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::normalizeDivision ( blocktriple< fbits, BlockTripleOperator::DIV, bt > & tgt) const
inlineconstexpr

◆ normalizeMultiplication()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::normalizeMultiplication ( blocktriple< fbits, BlockTripleOperator::MUL, bt > & tgt) const
inlineconstexpr

◆ operator double()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::operator double ( ) const
inlineexplicitnoexcept

◆ operator float()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::operator float ( ) const
inlineexplicitnoexcept

◆ operator int()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::operator int ( ) const
inlineexplicitnoexcept

◆ operator long double()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::operator long double ( ) const
inlineexplicitnoexcept

◆ operator long long()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
sw::universal::areal< _nbits, _es, bt >::operator long long ( ) const
inlineexplicitnoexcept

◆ operator*=() [1/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator*= ( const areal< _nbits, _es, bt > & rhs)
inlineconstexpr

◆ operator*=() [2/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator*= ( double rhs)
inlineconstexpr

◆ operator++() [1/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator++ ( )
inlineconstexpr

move to the next bit encoding modulo 2^nbits

Template Parameters
bt

◆ operator++() [2/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal sw::universal::areal< _nbits, _es, bt >::operator++ ( int )
inlineconstexpr

◆ operator+=() [1/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator+= ( const areal< _nbits, _es, bt > & rhs)
inlineconstexpr

◆ operator+=() [2/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator+= ( double rhs)
inlineconstexpr

◆ operator-()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal sw::universal::areal< _nbits, _es, bt >::operator- ( ) const
inlineconstexprnoexcept

◆ operator--() [1/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator-- ( )
inlineconstexpr

move to the previous bit encoding modulo 2^nbits (the symmetric inverse of operator++).

000...000 wraps to 111...111.

◆ operator--() [2/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal sw::universal::areal< _nbits, _es, bt >::operator-- ( int )
inlineconstexpr

◆ operator-=() [1/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator-= ( const areal< _nbits, _es, bt > & rhs)
inlineconstexpr

◆ operator-=() [2/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator-= ( double rhs)
inlineconstexpr

◆ operator/=() [1/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator/= ( const areal< _nbits, _es, bt > & rhs)
inlineconstexpr

◆ operator/=() [2/2]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator/= ( double rhs)
inlineconstexpr

◆ operator=() [1/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( areal< _nbits, _es, bt > && )
constexprdefaultnoexcept

◆ operator=() [2/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( char rhs)
inlineconstexpr

◆ operator=() [3/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( const areal< _nbits, _es, bt > & )
constexprdefaultnoexcept

◆ operator=() [4/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
CONSTEXPRESSION areal & sw::universal::areal< _nbits, _es, bt >::operator= ( double rhs)
inline

◆ operator=() [5/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
CONSTEXPRESSION areal & sw::universal::areal< _nbits, _es, bt >::operator= ( float rhs)
inline

◆ operator=() [6/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( int rhs)
inlineconstexpr

◆ operator=() [7/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
CONSTEXPRESSION areal & sw::universal::areal< _nbits, _es, bt >::operator= ( long double rhs)
inline

◆ operator=() [8/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( long long rhs)
inlineconstexpr

◆ operator=() [9/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( long rhs)
inlineconstexpr

◆ operator=() [10/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( short rhs)
inlineconstexpr

◆ operator=() [11/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( signed char rhs)
inlineconstexpr

◆ operator=() [12/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( unsigned int rhs)
inlineconstexpr

◆ operator=() [13/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( unsigned long long rhs)
inlineconstexpr

◆ operator=() [14/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( unsigned long rhs)
inlineconstexpr

◆ operator=() [15/15]

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::operator= ( unsigned short rhs)
inlineconstexpr

◆ reset()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::reset ( unsigned i)
inlineconstexprnoexcept

reset a specific bit in the encoding to false.

If bit index is out of bounds, no modification takes place.

Parameters
ibit index to reset

◆ round()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned srcbits, typename StorageType>
uint64_t sw::universal::areal< _nbits, _es, bt >::round ( StorageType raw,
int & exponent )
inlineconstexprprotectednoexcept

round a set of source bits to the present representation.

srcbits is the number of bits of significant in the source representation

Template Parameters
StorageType
Parameters
rawthe source bits
exponentthe exponent, incremented when rounding carries into the next binade
Returns
the rounded bits

◆ saturate_reserved()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::saturate_reserved ( )
inlineconstexprnoexcept

◆ scale()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
int sw::universal::areal< _nbits, _es, bt >::scale ( ) const
inlineconstexpr

◆ set()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::set ( unsigned i,
bool v = true )
inlineconstexprnoexcept

set a specific bit in the encoding to true or false.

If bit index is out of bounds, no modification takes place.

Parameters
ibit index to set
vboolean value to set the bit to. Default is true.

◆ setbits()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal & sw::universal::areal< _nbits, _es, bt >::setbits ( uint64_t raw_bits)
inlineconstexprnoexcept

set the raw bits of the areal.

This is a required API function for number systems in the Universal Numbers Library This enables verification test suites to inject specific test bit patterns using a common interface.

Parameters
raw_bitsunsigned long long carrying bits that will be written verbatim to the areal
Returns
reference to the areal

◆ setinf()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::setinf ( bool sign = true)
inlineconstexprnoexcept

set the number to +inf

Parameters
signboolean to make it + or - infinity, default is -inf

◆ setnan()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::setnan ( int NaNType = NAN_TYPE_SIGNALLING)
inlineconstexprnoexcept

set the number to a quiet NaN (+nan) or a signalling NaN (-nan, default)

Parameters
NaNTypeNAN_TYPE_QUIET or NAN_TYPE_SIGNALLING (the default)

◆ setsign()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::setsign ( bool sign = true)
inlineconstexprnoexcept

set the sign bit of the areal

Parameters
signtrue for negative, false for positive

◆ setzero()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::setzero ( )
inlineconstexprnoexcept

set the number to +0

◆ shiftLeft()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::shiftLeft ( int bitsToShift)
inlineprotected

◆ shiftRight()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
void sw::universal::areal< _nbits, _es, bt >::shiftRight ( int bitsToShift)
inlineprotected

◆ sign()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::sign ( ) const
inlineconstexprnoexcept

◆ test()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::test ( unsigned bitIndex) const
inlineconstexprnoexcept

◆ to_long()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
long sw::universal::areal< _nbits, _es, bt >::to_long ( ) const
inline

◆ to_long_long()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
long long sw::universal::areal< _nbits, _es, bt >::to_long_long ( ) const
inline

◆ to_native()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<typename TargetFloat>
TargetFloat sw::universal::areal< _nbits, _es, bt >::to_native ( ) const
inline

◆ ubit()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::ubit ( ) const
inlineconstexprnoexcept

◆ zero()

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
areal< nbits, es, bt > & sw::universal::areal< _nbits, _es, bt >::zero ( )
inlineconstexprnoexcept

◆ operator!=

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned nnbits, unsigned nes, typename nbt>
bool operator!= ( const areal< nnbits, nes, nbt > & lhs,
const areal< nnbits, nes, nbt > & rhs )
friend

◆ operator<

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned nnbits, unsigned nes, typename nbt>
bool operator< ( const areal< nnbits, nes, nbt > & lhs,
const areal< nnbits, nes, nbt > & rhs )
friend

◆ operator<<

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned nnbits, unsigned nes, typename nbt>
std::ostream & operator<< ( std::ostream & ostr,
const areal< nnbits, nes, nbt > & r )
friend

◆ operator<=

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned nnbits, unsigned nes, typename nbt>
bool operator<= ( const areal< nnbits, nes, nbt > & lhs,
const areal< nnbits, nes, nbt > & rhs )
friend

◆ operator==

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned nnbits, unsigned nes, typename nbt>
bool operator== ( const areal< nnbits, nes, nbt > & lhs,
const areal< nnbits, nes, nbt > & rhs )
friend

◆ operator>

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned nnbits, unsigned nes, typename nbt>
bool operator> ( const areal< nnbits, nes, nbt > & lhs,
const areal< nnbits, nes, nbt > & rhs )
friend

◆ operator>=

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
template<unsigned nnbits, unsigned nes, typename nbt>
bool operator>= ( const areal< nnbits, nes, nbt > & lhs,
const areal< nnbits, nes, nbt > & rhs )
friend

Member Data Documentation

◆ abits

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::abits = fhbits + 3ull
staticconstexpr

◆ ALLONES

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bt sw::universal::areal< _nbits, _es, bt >::ALLONES = bt(~0)
staticconstexpr

◆ bitsInBlock

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::bitsInBlock = sizeof(bt) * bitsInByte
staticconstexpr

◆ bitsInByte

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::bitsInByte = 8ull
staticconstexpr

◆ bitsInMSU

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::bitsInMSU = bitsInBlock - (nrBlocks * bitsInBlock - nbits)
staticconstexpr

◆ BLOCK_MASK

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bt sw::universal::areal< _nbits, _es, bt >::BLOCK_MASK = bt(-1)
staticconstexpr

◆ divbits

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::divbits = 3ull * fhbits + 4ull
staticconstexpr

◆ es

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::es = _es
staticconstexpr

◆ EXP_BIAS

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
int sw::universal::areal< _nbits, _es, bt >::EXP_BIAS = ((1l << (es - 1ull)) - 1l)
staticconstexpr

◆ EXP_SHIFT

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::EXP_SHIFT = (MSU_CAPTURES_E ? (1 == nrBlocks ? (nbits - 1ull - es) : (bitsInMSU - 1ull - es)) : 0)
staticconstexpr

◆ fbits

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::fbits = nbits - 2ull - es
staticconstexpr

◆ fhbits

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::fhbits = fbits + 1ull
staticconstexpr

◆ LSB_BIT_MASK

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bt sw::universal::areal< _nbits, _es, bt >::LSB_BIT_MASK = bt(1ull)
staticconstexpr

◆ MAX_EXP

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
int sw::universal::areal< _nbits, _es, bt >::MAX_EXP = (1l << es) - 1l - EXP_BIAS
staticconstexpr

◆ mbits

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::mbits = 2ull * fhbits
staticconstexpr

◆ MIN_EXP_NORMAL

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
int sw::universal::areal< _nbits, _es, bt >::MIN_EXP_NORMAL = 1 - EXP_BIAS
staticconstexpr

◆ MIN_EXP_SUBNORMAL

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
int sw::universal::areal< _nbits, _es, bt >::MIN_EXP_SUBNORMAL = 1 - EXP_BIAS - int(fbits)
staticconstexpr

◆ MSU

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::MSU = nrBlocks - 1ull
staticconstexpr

◆ MSU_CAPTURES_E

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bool sw::universal::areal< _nbits, _es, bt >::MSU_CAPTURES_E = (1ull + es) <= bitsInMSU
staticconstexpr

◆ MSU_EXP_MASK

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bt sw::universal::areal< _nbits, _es, bt >::MSU_EXP_MASK = ((ALLONES << EXP_SHIFT) & ~SIGN_BIT_MASK) & MSU_MASK
staticconstexpr

◆ MSU_MASK

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bt sw::universal::areal< _nbits, _es, bt >::MSU_MASK = (ALLONES >> (nrBlocks * bitsInBlock - nbits))
staticconstexpr

◆ nbits

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::nbits = _nbits
staticconstexpr

◆ nrBlocks

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
unsigned sw::universal::areal< _nbits, _es, bt >::nrBlocks = 1ull + ((nbits - 1ull) / bitsInBlock)
staticconstexpr

◆ SIGN_BIT_MASK

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
bt sw::universal::areal< _nbits, _es, bt >::SIGN_BIT_MASK = bt(bt(1ull) << ((nbits - 1ull) % bitsInBlock))
staticconstexpr

◆ storageMask

template<unsigned _nbits, unsigned _es, typename bt = uint8_t>
uint64_t sw::universal::areal< _nbits, _es, bt >::storageMask = (0xFFFFFFFFFFFFFFFFull >> (64ull - bitsInBlock))
staticconstexpr

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