Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
integer_impl.hpp File Reference

Classes

struct  sw::universal::idiv_t< nbits, BlockType, NumberType >
class  sw::universal::integer< _nbits, bt, _NumberType >

Namespaces

namespace  sw
 required std libraries
namespace  sw::universal

Macros

#define INTEGER_ENABLE_LITERALS   1
#define INTEGER_THROW_DIVIDE_BY_ZERO   UNIVERSAL_HAS_EXCEPTIONS
#define INTEGER_THROW_ARITHMETIC_EXCEPTION   0

Enumerations

enum class  sw::universal::IntegerNumberType { sw::universal::IntegerNumber = 0 , sw::universal::WholeNumber = 1 , sw::universal::NaturalNumber = 2 }

Functions

template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
long sw::universal::scale (const integer< nbits, BlockType, NumberType > &i)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > & sw::universal::convert (int64_t v, integer< nbits, BlockType, NumberType > &result)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > & sw::universal::convert (uint64_t v, integer< nbits, BlockType, NumberType > &result)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
bool sw::universal::parse (const std::string &number, integer< nbits, BlockType, NumberType > &value)
 stream operators
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::abs (const integer< nbits, BlockType, NumberType > &a)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::onesComplement (const integer< nbits, BlockType, NumberType > &value)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::twosComplement (const integer< nbits, BlockType, NumberType > &value)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr signed sw::universal::findMsb (const integer< nbits, BlockType, NumberType > &v)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
void sw::universal::remainder (integer< nbits, BlockType, NumberType > &c, const integer< nbits, BlockType, NumberType > &a, const integer< nbits, BlockType, NumberType > &b)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr void sw::universal::divide_magnitudes (const integer< nbits, BlockType, NumberType > &a, const integer< nbits, BlockType, NumberType > &b, integer< nbits, BlockType, NumberType > &q, integer< nbits, BlockType, NumberType > &r) noexcept
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr idiv_t< nbits, BlockType, NumberType > sw::universal::idiv (const integer< nbits, BlockType, NumberType > &, const integer< nbits, BlockType, NumberType > &b)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator== (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator!= (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator< (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator> (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator<= (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator>= (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType, typename IntType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::literal_operand (IntType v) noexcept
template<IntegerNumberType NumberType, typename IntType>
constexpr bool sw::universal::literal_below_domain (IntType v) noexcept
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType, typename IntType>
constexpr bool sw::universal::operator== (const integer< nbits, BlockType, NumberType > &lhs, IntType rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType, typename IntType>
constexpr bool sw::universal::operator!= (const integer< nbits, BlockType, NumberType > &lhs, IntType rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType, typename IntType>
constexpr bool sw::universal::operator< (const integer< nbits, BlockType, NumberType > &lhs, IntType rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType, typename IntType>
constexpr bool sw::universal::operator> (const integer< nbits, BlockType, NumberType > &lhs, IntType rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType, typename IntType>
constexpr bool sw::universal::operator<= (const integer< nbits, BlockType, NumberType > &lhs, IntType rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType, typename IntType>
constexpr bool sw::universal::operator>= (const integer< nbits, BlockType, NumberType > &lhs, IntType rhs)
template<typename IntType, unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator== (IntType lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<typename IntType, unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator!= (IntType lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<typename IntType, unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator< (IntType lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<typename IntType, unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator> (IntType lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<typename IntType, unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator<= (IntType lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<typename IntType, unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr bool sw::universal::operator>= (IntType lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator<< (const integer< nbits, BlockType, NumberType > &lhs, int shift)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator>> (const integer< nbits, BlockType, NumberType > &lhs, int shift)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator+ (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator- (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator* (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator/ (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator% (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator& (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator| (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator^ (const integer< nbits, BlockType, NumberType > &lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::arithmetic_literal (long long v)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator+ (const integer< nbits, BlockType, NumberType > &lhs, long long rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator- (const integer< nbits, BlockType, NumberType > &lhs, long long rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator* (const integer< nbits, BlockType, NumberType > &lhs, long long rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator/ (const integer< nbits, BlockType, NumberType > &lhs, long long rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator% (const integer< nbits, BlockType, NumberType > &lhs, long long rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator& (const integer< nbits, BlockType, NumberType > &lhs, long long rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator| (const integer< nbits, BlockType, NumberType > &lhs, long long rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator^ (const integer< nbits, BlockType, NumberType > &lhs, long long rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator+ (long long lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator- (long long lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator* (long long lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator/ (long long lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator% (long long lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator& (long long lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator| (long long lhs, const integer< nbits, BlockType, NumberType > &rhs)
template<unsigned nbits, typename BlockType, IntegerNumberType NumberType>
constexpr integer< nbits, BlockType, NumberType > sw::universal::operator^ (long long lhs, const integer< nbits, BlockType, NumberType > &rhs)

Variables

constexpr IntegerNumberType sw::universal::IntegerNumber = IntegerNumberType::IntegerNumber
constexpr IntegerNumberType sw::universal::WholeNumber = IntegerNumberType::WholeNumber
constexpr IntegerNumberType sw::universal::NaturalNumber = IntegerNumberType::NaturalNumber

Macro Definition Documentation

◆ INTEGER_ENABLE_LITERALS

#define INTEGER_ENABLE_LITERALS   1

◆ INTEGER_THROW_ARITHMETIC_EXCEPTION

#define INTEGER_THROW_ARITHMETIC_EXCEPTION   0

◆ INTEGER_THROW_DIVIDE_BY_ZERO

#define INTEGER_THROW_DIVIDE_BY_ZERO   UNIVERSAL_HAS_EXCEPTIONS