Arduino Filters master
Filter library for Arduino
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
FixedPoint< T, N, T2 > Class Template Reference

#include <Filters/FixedPoint.hpp>

Detailed Description

template<class T, uint8_t N, class T2 = DoubleWidthInt_t<T>>
class FixedPoint< T, N, T2 >

Very basic fixed-point integer implementation.

Template Parameters
TThe integer type to use.
NThe number of fractional bits.
T2The integer type to use for intermediate values when mutliplying or dividing.

Definition at line 64 of file FixedPoint.hpp.

+ Collaboration diagram for FixedPoint< T, N, T2 >:

Public Member Functions

 FixedPoint ()
 Default constructor. More...
 
template<class U >
 FixedPoint (U f)
 Initialize U from a numeric value. More...
 
FixedPoint operator+ (FixedPoint rhs) const
 Addition. More...
 
FixedPoint operator- (FixedPoint rhs) const
 Subtraction. More...
 
FixedPoint operator- () const
 Invert. More...
 
FixedPoint operator* (FixedPoint rhs) const
 Multiplication. More...
 
T2 operator* (T2 rhs) const
 Multiplication with normal integer. More...
 
FixedPoint operator/ (FixedPoint rhs) const
 Division. More...
 
 operator long double () const
 
 operator double () const
 
 operator float () const
 

Static Public Member Functions

static constexpr FixedPoint raw (T t)
 Convert a raw integer representation to fixed point type. More...
 
static T div_N (T2 val)
 Divide the given integer by \( 2^N \). More...
 

Static Public Attributes

static constexpr T one = 1 << N
 Fixed-point representation of the number one. More...
 

Private Attributes

val
 

Constructor & Destructor Documentation

◆ FixedPoint() [1/2]

FixedPoint ( )
inline

Default constructor.

Definition at line 70 of file FixedPoint.hpp.

◆ FixedPoint() [2/2]

FixedPoint ( f)
inline

Initialize U from a numeric value.

Definition at line 74 of file FixedPoint.hpp.

Member Function Documentation

◆ raw()

static constexpr FixedPoint raw ( t)
inlinestaticconstexpr

Convert a raw integer representation to fixed point type.

Definition at line 77 of file FixedPoint.hpp.

◆ operator+()

FixedPoint operator+ ( FixedPoint< T, N, T2 >  rhs) const
inline

Addition.

Definition at line 84 of file FixedPoint.hpp.

◆ operator-() [1/2]

FixedPoint operator- ( FixedPoint< T, N, T2 >  rhs) const
inline

Subtraction.

Definition at line 101 of file FixedPoint.hpp.

◆ operator-() [2/2]

FixedPoint operator- ( ) const
inline

Invert.

Definition at line 107 of file FixedPoint.hpp.

◆ operator*() [1/2]

FixedPoint operator* ( FixedPoint< T, N, T2 >  rhs) const
inline

Multiplication.

Definition at line 110 of file FixedPoint.hpp.

◆ operator*() [2/2]

T2 operator* ( T2  rhs) const
inline

Multiplication with normal integer.

Definition at line 115 of file FixedPoint.hpp.

◆ operator/()

FixedPoint operator/ ( FixedPoint< T, N, T2 >  rhs) const
inline

Division.

Definition at line 118 of file FixedPoint.hpp.

◆ div_N()

static T div_N ( T2  val)
inlinestatic

Divide the given integer by \( 2^N \).

Definition at line 125 of file FixedPoint.hpp.

◆ operator long double()

operator long double ( ) const
inlineexplicit

Definition at line 132 of file FixedPoint.hpp.

◆ operator double()

operator double ( ) const
inlineexplicit

Definition at line 133 of file FixedPoint.hpp.

◆ operator float()

operator float ( ) const
inlineexplicit

Definition at line 134 of file FixedPoint.hpp.

Member Data Documentation

◆ one

constexpr T one = 1 << N
staticconstexpr

Fixed-point representation of the number one.

Definition at line 67 of file FixedPoint.hpp.

◆ val

T val
private

Definition at line 137 of file FixedPoint.hpp.


The documentation for this class was generated from the following file: