|
Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
|
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) |
An arbitrary configuration real number with gradual under/overflow and uncertainty bit.
| nbits | number of bits in the encoding |
| es | number of exponent bits in the encoding |
| bt | the type to use as storage class: one of [uint8_t|uint16_t|uint32_t] |
| using sw::universal::areal< _nbits, _es, bt >::BlockType = bt |
|
inlineconstexprnoexcept |
|
constexprdefaultnoexcept |
|
constexprdefaultnoexcept |
|
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.
| rhs | the source areal |
|
inlineconstexpr |
|
inlineconstexprnoexcept |
construct an areal from a native type, specialized for size
| iv | initial value to construct |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inline |
|
inlineprotected |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
clear the content of this areal to zero
| void sw::universal::areal< nbits, es, bt >::constexprClassParameters | ( | ) | const |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprprotected |
|
inlineconstexpr |
|
inlineconstexprnoexcept |
1's complement of the encoding
|
inlineconstexpr |
|
inlineconstexprnoexcept |
|
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
| InfType | default is 0, both types, -1 checks for -inf, 1 checks for +inf |
|
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
| NaNType | default is 0, both types, 1 checks for Signalling NaN, -1 checks for Quiet NaN |
|
inlineconstexpr |
|
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
|
inlineconstexpr |
|
inlineconstexpr |
|
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
|
inlineconstexpr |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineexplicitnoexcept |
|
inlineexplicitnoexcept |
|
inlineexplicitnoexcept |
|
inlineexplicitnoexcept |
|
inlineexplicitnoexcept |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
move to the next bit encoding modulo 2^nbits
| bt |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexprnoexcept |
|
inlineconstexpr |
move to the previous bit encoding modulo 2^nbits (the symmetric inverse of operator++).
000...000 wraps to 111...111.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
constexprdefaultnoexcept |
|
inlineconstexpr |
|
constexprdefaultnoexcept |
|
inline |
|
inline |
|
inlineconstexpr |
|
inline |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexprnoexcept |
reset a specific bit in the encoding to false.
If bit index is out of bounds, no modification takes place.
| i | bit index to reset |
|
inlineconstexprprotectednoexcept |
round a set of source bits to the present representation.
srcbits is the number of bits of significant in the source representation
| StorageType |
| raw | the source bits |
| exponent | the exponent, incremented when rounding carries into the next binade |
|
inlineconstexprnoexcept |
|
inlineconstexpr |
|
inlineconstexprnoexcept |
set a specific bit in the encoding to true or false.
If bit index is out of bounds, no modification takes place.
| i | bit index to set |
| v | boolean value to set the bit to. Default is true. |
|
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.
| raw_bits | unsigned long long carrying bits that will be written verbatim to the areal |
|
inlineconstexprnoexcept |
set the number to +inf
| sign | boolean to make it + or - infinity, default is -inf |
|
inlineconstexprnoexcept |
set the number to a quiet NaN (+nan) or a signalling NaN (-nan, default)
| NaNType | NAN_TYPE_QUIET or NAN_TYPE_SIGNALLING (the default) |
|
inlineconstexprnoexcept |
set the sign bit of the areal
| sign | true for negative, false for positive |
|
inlineconstexprnoexcept |
set the number to +0
|
inlineprotected |
|
inlineprotected |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inline |
|
inline |
|
inline |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |