fixed_point (deprecated)  rev.2
Binary Fixed-Point Arithmetic Library in C++
Public Types | Public Member Functions | Static Public Attributes | List of all members
sg14::elastic_integer< Digits, Narrowest > Class Template Reference

literal integer type that encodes its width in bits within its type More...

#include <sg14/auxiliary/elastic_integer.h>

Inherits base_class_t< Digits, Narrowest >.

Public Types

using narrowest = Narrowest
 alias to template parameter, Narrowest
 
using rep = typename _base::rep
 the actual type used to store the value; closely related to Narrowest but may be a different width
 

Public Member Functions

constexpr elastic_integer ()=default
 default constructor
 
constexpr elastic_integer (const elastic_integer &rhs)
 common copy constructor
 
template<class Number , _impl::enable_if_t< std::numeric_limits< Number >::is_specialized, int > Dummy = 0>
constexpr elastic_integer (Number n)
 construct from numeric type
 
template<int FromWidth, class FromNarrowest >
constexpr elastic_integer (const elastic_integer< FromWidth, FromNarrowest > &rhs)
 constructor taking an elastic_integer type
 
template<class Integral , Integral Value, int Exponent>
constexpr elastic_integer (const_integer< Integral, Value, Digits, Exponent >)
 constructor taking an integral constant
 
template<class S >
constexpr operator S () const
 returns value
 
template<class S , _impl::enable_if_t< std::is_floating_point< S >::value, int > Dummy = 0>
elastic_integeroperator= (S s)
 copy assignment operator taking a floating-point type
 

Static Public Attributes

static constexpr int digits = Digits
 alias to template parameter, Digits
 

Detailed Description

template<int Digits, class Narrowest = int>
class sg14::elastic_integer< Digits, Narrowest >

literal integer type that encodes its width in bits within its type

Template Parameters
Digitsa count of the number of digits needed to express the number
Narrowestthe most narrow integer type to use for storage
Note
Arithmetic operations result in types with an adjusted Digits parameter accordingly. For instance, when two elastic_integer values are multiplied together, the resultant type has Digits set to the sum of the operands.
See also
elastic_fixed_point