CMSIS-DSP  
CMSIS DSP Software Library
 
Loading...
Searching...
No Matches
Fixed point datatypes

Data Structures

struct  fixed_storage_type< M, F, s, bool >
 Storage type for a fixed point number. More...
 
struct  fixed_storage_type< M, F, true, test64(M, F, 1)>
 Storage type for a fixed point number representable on int64. More...
 
struct  fixed_storage_type< M, F, false, test64(M, F, 0)>
 Storage type for a fixed point number representable on uint64. More...
 
struct  fixed_storage_type< M, F, true, test32(M, F, 1)>
 Storage type for a fixed point number representable on int32. More...
 
struct  fixed_storage_type< M, F, false, test32(M, F, 0)>
 Storage type for a fixed point number representable on uint32. More...
 
struct  fixed_storage_type< M, F, true, test16(M, F, 1)>
 Storage type for a fixed point number representable on int16. More...
 
struct  fixed_storage_type< M, F, false, test16(M, F, 0)>
 Storage type for a fixed point number representable on uint16. More...
 
struct  fixed_storage_type< M, F, true, test8(M, F, 1)>
 Storage type for a fixed point number representable on int8. More...
 
struct  fixed_storage_type< M, F, false, test8(M, F, 0)>
 Storage type for a fixed point number representable on uint8. More...
 
struct  Q< M, F, S, T >
 Fixed point template. More...
 
struct  Q< M, F, true, int64_t >
 Signed fixed point datatypes on 64 bits. More...
 
struct  Q< M, F, false, uint64_t >
 Unsigned fixed point datatypes on 64 bits. More...
 
struct  Q< M, F, true, int32_t >
 Signed fixed point datatypes on 32 bits. More...
 
struct  Q< M, F, false, uint32_t >
 Unsigned fixed point datatypes on 32 bits. More...
 
struct  Q< M, F, true, int16_t >
 Signed fixed point datatypes on 16 bits. More...
 
struct  Q< M, F, false, uint16_t >
 Unsigned fixed point datatypes on 16 bits. More...
 
struct  Q< M, F, true, int8_t >
 Signed fixed point datatypes on 8 bits. More...
 
struct  Q< M, F, false, uint8_t >
 Unsigned fixed point datatypes on 8 bits. More...
 
struct  FixedCastShift< M, FD, FS, S,(FD >FS)>
 Changed fractional representation of a fixed point number using a shift. More...
 
struct  FixedCastShift< M, FD, FS, S,(FD< FS)>
 Changed fractional representation of a fixed point number using a shift. More...
 
struct  Accumulate< MD, MS, F, S, bool >
 Accumulation without saturation. More...
 
struct  Accumulate< MD, MS, F, S, true >
 Accumulation without saturation. More...
 

Typedefs

using Q63 = Q< 0, 63 >
 Q63 datatype.
 
using Q31 = Q< 0, 31 >
 Q31 datatype.
 
using Q15 = Q< 0, 15 >
 Q15 datatype.
 
using Q7 = Q< 0, 7 >
 Q7 datatype.
 

Functions

constexpr bool test64 (const int M, const int F, const int S)
 Function to identify the template for fixed number representable on 64 bits.
 
constexpr bool test32 (const int M, const int F, const int S)
 Function to identify the template for fixed number representable on 32 bits.
 
constexpr bool test16 (const int M, const int F, const int S)
 Function to identify the template for fixed number representable on 16 bits.
 
constexpr bool test8 (const int M, const int F, const int S)
 Function to identify the template for fixed number representable on 8 bits.
 
constexpr Q63 operator""_q63 (long double x)
 q63 literal
 
constexpr Q31 operator""_q31 (long double x)
 q31 literal
 
constexpr Q15 operator""_q15 (long double x)
 q15 literal
 
constexpr Q7 operator""_q7 (long double x)
 q7 literal
 
template<int MA, int FA, int MB, int FB, bool SA, bool SB>
Q< MA+MB+1, FA+FB, SA||SB > mult (const Q< MA, FA, SA > &a, const Q< MB, FB, SB > &b)
 Multiplication of two fixed point numbers A and B.
 
template<int M, int F, bool S>
Q< M, F, S > operator+ (const Q< M, F, S > &a, const Q< M, F, S > &b)
 Add two fixed point numbers with saturation.
 
template<int M, int F, bool S>
Q< M, F, S > operator- (const Q< M, F, S > &a, const Q< M, F, S > &b)
 Subtract two fixed point numbers with saturation.
 
template<int M, int F, bool S>
Q< M, F, S > operator- (const Q< M, F, S > &a)
 Negate a fixed point number with saturation.
 
template<int M, int F, bool S>
Q< M, F, S > add (const Q< M, F, S > &a, const Q< M, F, S > &b)
 Add two fixed point numbers without saturation.
 
template<int M, int F, bool S>
Q< M, F, S > sub (const Q< M, F, S > &a, const Q< M, F, S > &b)
 Subtract two fixed point numbers without saturation.
 
template<int M, int F, int N, bool S>
Q< M, F, S > operator>> (const Q< M, F, S > &a, std::integral_constant< int, N >) noexcept
 Shift right a fixed point number with a shift known at build time.
 
template<int M, int F, int N, bool S>
Q< M+N, F, S > operator<< (const Q< M, F, S > &a, std::integral_constant< int, N >) noexcept
 Shift left a fixed point number with a shift known at build time.
 
template<int MD = 0, int MS, int F>
Q< MD, F, true > saturate (const Q< MS, F, true > &src, typename std::enable_if<(MD< MS) &&((MD+F)< 31)>::type *=nullptr)
 Saturate a signed fixed point number.
 
template<int MD = 0, int MS, int F>
Q< MD, F, false > saturate (const Q< MS, F, false > &src, typename std::enable_if<(MD< MS) &&((MD+F)< 31)>::type *=nullptr)
 Saturate an unsigned fixed point number.
 
template<int FD, int M, int FS, bool S>
Q< M, FD, S > toFrac (const Q< M, FS, S > &src)
 Convert between different fractional part formats.
 
template<int MD, int MS, int F, bool S>
Q< MD, F, S > accumulate (const Q< MD, F, S > &a, const Q< MS, F, S > &b)
 Accumulate without saturation.
 
Q7 operator* (const Q7 &a, const Q7 &b)
 Multiplication operator.
 
Q15 operator* (const Q15 &a, const Q15 &b)
 Multiplication operator.
 
Q31 operator* (const Q31 &a, const Q31 &b)
 Multiplication operator.
 
template<int M, int F>
bool operator> (const Q< M, F > &a, const Q< M, F > &b)
 Greater-than comparison operator.
 
template<int M, int F>
bool operator< (const Q< M, F > &a, const Q< M, F > &b)
 Less-than comparison operator.
 
template<int M, int F>
bool operator>= (const Q< M, F > &a, const Q< M, F > &b)
 Greater-than-or-equal comparison operator.
 
template<int M, int F>
bool operator<= (const Q< M, F > &a, const Q< M, F > &b)
 Less-than-or-equal comparison operator.
 
template<int M, int F>
bool operator== (const Q< M, F > a, const Q< M, F > b)
 Equality operator.
 
template<int M, int F>
bool operator!= (const Q< M, F > a, const Q< M, F > b)
 Inequality operator.
 
template<int M, int F, bool S>
Q< M, F, S > operator/ (const Q< M, F, S > a, const int32_t b)
 Division operator.
 
template<int M, int F, bool S>
Q< M, F, S > operator+ (const Q< M, F, S > &a)
 No op operator.
 

Description


Data Structure Documentation

◆ arm_cmsis_dsp::fixed_storage_type

struct arm_cmsis_dsp::fixed_storage_type
template<int M, int F, bool s = true, bool = true>
struct arm_cmsis_dsp::fixed_storage_type< M, F, s, bool >

Storage type for a fixed point number.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part
ssigned or unsigned

◆ arm_cmsis_dsp::fixed_storage_type< M, F, true, test64(M, F, 1)>

struct arm_cmsis_dsp::fixed_storage_type< M, F, true, test64(M, F, 1)>
template<int M, int F>
struct arm_cmsis_dsp::fixed_storage_type< M, F, true, test64(M, F, 1)>

Storage type for a fixed point number representable on int64.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

typedef int64_t value_type
 Storage for the fixed point number.
 
typedef int64_t wider_type
 Storage for the widening of this fixed point number datatype.
 
typedef int32_t narrow_type
 Storage for the narrowing of this fixed point number datatype.
 

◆ arm_cmsis_dsp::fixed_storage_type< M, F, false, test64(M, F, 0)>

struct arm_cmsis_dsp::fixed_storage_type< M, F, false, test64(M, F, 0)>
template<int M, int F>
struct arm_cmsis_dsp::fixed_storage_type< M, F, false, test64(M, F, 0)>

Storage type for a fixed point number representable on uint64.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

typedef uint64_t value_type
 Storage for the fixed point number.
 
typedef uint64_t wider_type
 Storage for the widening of this fixed point number datatype.
 
typedef uint32_t narrow_type
 Storage for the narrowing of this fixed point number datatype.
 

◆ arm_cmsis_dsp::fixed_storage_type< M, F, true, test32(M, F, 1)>

struct arm_cmsis_dsp::fixed_storage_type< M, F, true, test32(M, F, 1)>
template<int M, int F>
struct arm_cmsis_dsp::fixed_storage_type< M, F, true, test32(M, F, 1)>

Storage type for a fixed point number representable on int32.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

typedef int32_t value_type
 Storage for the fixed point number.
 
typedef int64_t wider_type
 Storage for the widening of this fixed point number datatype.
 
typedef int16_t narrow_type
 Storage for the narrowing of this fixed point number datatype.
 

◆ arm_cmsis_dsp::fixed_storage_type< M, F, false, test32(M, F, 0)>

struct arm_cmsis_dsp::fixed_storage_type< M, F, false, test32(M, F, 0)>
template<int M, int F>
struct arm_cmsis_dsp::fixed_storage_type< M, F, false, test32(M, F, 0)>

Storage type for a fixed point number representable on uint32.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

typedef uint32_t value_type
 Storage for the fixed point number.
 
typedef uint64_t wider_type
 Storage for the widening of this fixed point number datatype.
 
typedef uint16_t narrow_type
 Storage for the narrowing of this fixed point number datatype.
 

◆ arm_cmsis_dsp::fixed_storage_type< M, F, true, test16(M, F, 1)>

struct arm_cmsis_dsp::fixed_storage_type< M, F, true, test16(M, F, 1)>
template<int M, int F>
struct arm_cmsis_dsp::fixed_storage_type< M, F, true, test16(M, F, 1)>

Storage type for a fixed point number representable on int16.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

typedef int16_t value_type
 Storage for the fixed point number.
 
typedef int32_t wider_type
 Storage for the widening of this fixed point number datatype.
 
typedef int8_t narrow_type
 Storage for the narrowing of this fixed point number datatype.
 

◆ arm_cmsis_dsp::fixed_storage_type< M, F, false, test16(M, F, 0)>

struct arm_cmsis_dsp::fixed_storage_type< M, F, false, test16(M, F, 0)>
template<int M, int F>
struct arm_cmsis_dsp::fixed_storage_type< M, F, false, test16(M, F, 0)>

Storage type for a fixed point number representable on uint16.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

typedef uint16_t value_type
 Storage for the fixed point number.
 
typedef uint32_t wider_type
 Storage for the widening of this fixed point number datatype.
 
typedef uint8_t narrow_type
 Storage for the narrowing of this fixed point number datatype.
 

◆ arm_cmsis_dsp::fixed_storage_type< M, F, true, test8(M, F, 1)>

struct arm_cmsis_dsp::fixed_storage_type< M, F, true, test8(M, F, 1)>
template<int M, int F>
struct arm_cmsis_dsp::fixed_storage_type< M, F, true, test8(M, F, 1)>

Storage type for a fixed point number representable on int8.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

typedef int8_t value_type
 Storage for the fixed point number.
 
typedef int16_t wider_type
 Storage for the widening of this fixed point number datatype.
 
typedef int8_t narrow_type
 Storage for the narrowing of this fixed point number datatype.
 

◆ arm_cmsis_dsp::fixed_storage_type< M, F, false, test8(M, F, 0)>

struct arm_cmsis_dsp::fixed_storage_type< M, F, false, test8(M, F, 0)>
template<int M, int F>
struct arm_cmsis_dsp::fixed_storage_type< M, F, false, test8(M, F, 0)>

Storage type for a fixed point number representable on uint8.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

typedef uint8_t value_type
 Storage for the fixed point number.
 
typedef uint16_t wider_type
 Storage for the widening of this fixed point number datatype.
 
typedef uint8_t narrow_type
 Storage for the narrowing of this fixed point number datatype.
 

◆ arm_cmsis_dsp::Q

struct arm_cmsis_dsp::Q
template<int M, int F, bool S = true, typename T = typename fixed_storage_type<M,F,S>::value_type>
struct arm_cmsis_dsp::Q< M, F, S, T >

Fixed point template.

Template Parameters
MNumber of bits for mantissa (without sign bit)#
FNumber of bits for fractional part
SSigned or unsigned
Tstorage datatype

◆ arm_cmsis_dsp::Q< M, F, true, int64_t >

struct arm_cmsis_dsp::Q< M, F, true, int64_t >
template<int M, int F>
struct arm_cmsis_dsp::Q< M, F, true, int64_t >

Signed fixed point datatypes on 64 bits.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

using value_type = typename fixed_storage_type< M, F, true >::value_type
 Storage type for the value.
 
using wider_type = typename fixed_storage_type< M, F, true >::wider_type
 Storage type for the widening of the value.
 

Public Member Functions

constexpr Q ()
 Create a new zero fixed point.
 
constexpr Q (const value_type x)
 Create a new fixed point from a raw integer.
 
constexpr Q (const Q< M, F, false > &other)
 Convert an unsigned fixed point to this fixed point.
 
bool operator== (const Q &b) const
 this == b
 
bool operator!= (const Q &b) const
 this != b
 
bool operator< (const Q &b) const
 this < b
 
bool operator> (const Q &b) const
 this > b
 
bool operator<= (const Q &b) const
 this <= b
 
bool operator>= (const Q &b) const
 this >= b
 
Qoperator+= (const Q other)
 this += other
 
Qoperator-= (const Q other)
 this -= other
 

Static Public Member Functions

static constexpr value_type convert (const float f)
 Convert a float to fixed point.
 
static constexpr Q f (const float x)
 Create a new fixed point from a float.
 
static constexpr Q one ()
 Fixed point number representing 1.
 

Data Fields

value_type v
 Storage value.
 

Static Public Attributes

static constexpr int fracBits = F
 Number of fractional bits.
 
static constexpr int mantissaBits = M
 Number of mantissa bits (without sign bit)
 
static constexpr bool isSigned = true
 Is this number representation signed.
 
static constexpr value_type maxVal = 0x7FFFFFFFFFFFFFFFLL
 Maximum representable positive value.
 
static constexpr value_type minVal = 0x8000000000000000LL
 Minimum representable negative value.
 

Constructor & Destructor Documentation

◆ Q() [1/2]

constexpr Q ( const value_type  x)
inlineexplicitconstexpr

Create a new fixed point from a raw integer.

Parameters
xthe raw integer

◆ Q() [2/2]

constexpr Q ( const Q< M, F, false > &  other)
inlineexplicitconstexpr

Convert an unsigned fixed point to this fixed point.

Parameters
otherThe unsigned fixed point number

Some problem may occur since the unsigned may not be representable with the less bits required for the sign representation. This convertion is not saturating.

Member Function Documentation

◆ convert()

static constexpr value_type convert ( const float  f)
inlinestaticconstexpr

Convert a float to fixed point.

Parameters
ffloat value
Returns
the fixed point value in the storage type

◆ f()

static constexpr Q f ( const float  x)
inlinestaticconstexpr

Create a new fixed point from a float.

Parameters
xthe float
Returns
The fixed point representing the float value with saturation

◆ one()

static constexpr Q one ( )
inlinestaticconstexpr

Fixed point number representing 1.

Returns
Fixed point representing 1

◆ operator!=()

bool operator!= ( const Q< M, F, true, int64_t > &  b) const
inline

this != b

Parameters
bthe other fixed point
Returns
true if this != b

◆ operator+=()

Q & operator+= ( const Q< M, F, true, int64_t >  other)
inline

this += other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator-=()

Q & operator-= ( const Q< M, F, true, int64_t >  other)
inline

this -= other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator<()

bool operator< ( const Q< M, F, true, int64_t > &  b) const
inline

this < b

Parameters
bthe other fixed point
Returns
true if this < b

◆ operator<=()

bool operator<= ( const Q< M, F, true, int64_t > &  b) const
inline

this <= b

Parameters
bthe other fixed point
Returns
true if this <= b

◆ operator==()

bool operator== ( const Q< M, F, true, int64_t > &  b) const
inline

this == b

Parameters
bthe other fixed point
Returns
true if this == b

◆ operator>()

bool operator> ( const Q< M, F, true, int64_t > &  b) const
inline

this > b

Parameters
bthe other fixed point
Returns
true if this > b

◆ operator>=()

bool operator>= ( const Q< M, F, true, int64_t > &  b) const
inline

this >= b

Parameters
bthe other fixed point
Returns
true if this >= b

◆ arm_cmsis_dsp::Q< M, F, false, uint64_t >

struct arm_cmsis_dsp::Q< M, F, false, uint64_t >
template<int M, int F>
struct arm_cmsis_dsp::Q< M, F, false, uint64_t >

Unsigned fixed point datatypes on 64 bits.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

using value_type = typename fixed_storage_type< M, F, false >::value_type
 Storage type for the value.
 
using wider_type = typename fixed_storage_type< M, F, false >::wider_type
 Storage type for the widening of the value.
 

Public Member Functions

constexpr Q ()
 Create a new zero fixed point.
 
constexpr Q (const value_type x)
 Create a new fixed point from a raw integer.
 
bool operator== (const Q &b) const
 this == b
 
bool operator!= (const Q &b) const
 this != b
 
bool operator< (const Q &b) const
 this < b
 
bool operator> (const Q &b) const
 this > b
 
bool operator<= (const Q &b) const
 this <= b
 
bool operator>= (const Q &b) const
 this >= b
 

Static Public Member Functions

static constexpr value_type convert (const float f)
 Convert a float to fixed point.
 
static constexpr Q f (const float x)
 Create a new fixed point from a float.
 
static constexpr Q one ()
 Fixed point number representing 1.
 

Data Fields

value_type v
 Storage value.
 

Static Public Attributes

static constexpr int fracBits = F
 Number of fractional bits.
 
static constexpr int mantissaBits = M
 Number of mantissa bits (without sign bit)
 
static constexpr bool isSigned = false
 Is this number representation signed.
 
static constexpr value_type maxVal = 0xFFFFFFFFFFFFFFFFLL
 Maximum representable positive value.
 

Constructor & Destructor Documentation

◆ Q()

constexpr Q ( const value_type  x)
inlineexplicitconstexpr

Create a new fixed point from a raw integer.

Parameters
xthe raw integer

Member Function Documentation

◆ convert()

static constexpr value_type convert ( const float  f)
inlinestaticconstexpr

Convert a float to fixed point.

Parameters
ffloat value
Returns
the fixed point value in the storage type

◆ f()

static constexpr Q f ( const float  x)
inlinestaticconstexpr

Create a new fixed point from a float.

Parameters
xthe float
Returns
The fixed point representing the float value with saturation

◆ one()

static constexpr Q one ( )
inlinestaticconstexpr

Fixed point number representing 1.

Returns
Fixed point representing 1

◆ operator!=()

bool operator!= ( const Q< M, F, false, uint64_t > &  b) const
inline

this != b

Parameters
bthe other fixed point
Returns
true if this != b

◆ operator<()

bool operator< ( const Q< M, F, false, uint64_t > &  b) const
inline

this < b

Parameters
bthe other fixed point
Returns
true if this < b

◆ operator<=()

bool operator<= ( const Q< M, F, false, uint64_t > &  b) const
inline

this <= b

Parameters
bthe other fixed point
Returns
true if this <= b

◆ operator==()

bool operator== ( const Q< M, F, false, uint64_t > &  b) const
inline

this == b

Parameters
bthe other fixed point
Returns
true if this == b

◆ operator>()

bool operator> ( const Q< M, F, false, uint64_t > &  b) const
inline

this > b

Parameters
bthe other fixed point
Returns
true if this > b

◆ operator>=()

bool operator>= ( const Q< M, F, false, uint64_t > &  b) const
inline

this >= b

Parameters
bthe other fixed point
Returns
true if this >= b

◆ arm_cmsis_dsp::Q< M, F, true, int32_t >

struct arm_cmsis_dsp::Q< M, F, true, int32_t >
template<int M, int F>
struct arm_cmsis_dsp::Q< M, F, true, int32_t >

Signed fixed point datatypes on 32 bits.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

using value_type = typename fixed_storage_type< M, F, true >::value_type
 Storage type for the value.
 
using wider_type = typename fixed_storage_type< M, F, true >::wider_type
 Storage type for the widening of the value.
 

Public Member Functions

constexpr Q ()
 Create a new zero fixed point.
 
constexpr Q (const value_type x)
 Create a new fixed point from a raw integer.
 
constexpr Q (const Q< M, F, false > &other)
 Convert an unsigned fixed point to this fixed point.
 
bool operator== (const Q &b) const
 this == b
 
bool operator!= (const Q &b) const
 this != b
 
bool operator< (const Q &b) const
 this < b
 
bool operator> (const Q &b) const
 this > b
 
bool operator<= (const Q &b) const
 this <= b
 
bool operator>= (const Q &b) const
 this >= b
 
Qoperator+= (const Q other)
 this += other
 
Qoperator-= (const Q other)
 this -= other
 

Static Public Member Functions

static constexpr value_type sat (const wider_type i)
 Saturate a wider type to the current type.
 
static constexpr value_type convert (const float f)
 Convert a float to fixed point with saturation.
 
static constexpr Q f (const float x)
 Create a new fixed point from a float.
 
static constexpr Q one ()
 Fixed point number representing 1.
 

Data Fields

value_type v
 Storage value.
 

Static Public Attributes

static constexpr int fracBits = F
 Number of fractional bits.
 
static constexpr int mantissaBits = M
 Number of mantissa bits (without sign bit)
 
static constexpr bool isSigned = true
 Is this number representation signed.
 
static constexpr value_type maxVal = 0x7FFFFFFFL
 Maximum representable positive value.
 
static constexpr value_type minVal = 0x80000000L
 Minimum representable negative value.
 

Constructor & Destructor Documentation

◆ Q() [1/2]

constexpr Q ( const value_type  x)
inlineexplicitconstexpr

Create a new fixed point from a raw integer.

Parameters
xthe raw integer

◆ Q() [2/2]

constexpr Q ( const Q< M, F, false > &  other)
inlineexplicitconstexpr

Convert an unsigned fixed point to this fixed point.

Parameters
otherThe unsigned fixed point number

Some problem may occur since the unsigned may not be representable with the less bits required for the sign representation. This convertion is not saturating.

Member Function Documentation

◆ convert()

static constexpr value_type convert ( const float  f)
inlinestaticconstexpr

Convert a float to fixed point with saturation.

Parameters
ffloat value
Returns
the fixed point value in the storage type

◆ f()

static constexpr Q f ( const float  x)
inlinestaticconstexpr

Create a new fixed point from a float.

Parameters
xthe float
Returns
The fixed point representing the float value with saturation

◆ one()

static constexpr Q one ( )
inlinestaticconstexpr

Fixed point number representing 1.

Returns
Fixed point representing 1

◆ operator!=()

bool operator!= ( const Q< M, F, true, int32_t > &  b) const
inline

this != b

Parameters
bthe other fixed point
Returns
true if this != b

◆ operator+=()

Q & operator+= ( const Q< M, F, true, int32_t >  other)
inline

this += other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator-=()

Q & operator-= ( const Q< M, F, true, int32_t >  other)
inline

this -= other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator<()

bool operator< ( const Q< M, F, true, int32_t > &  b) const
inline

this < b

Parameters
bthe other fixed point
Returns
true if this < b

◆ operator<=()

bool operator<= ( const Q< M, F, true, int32_t > &  b) const
inline

this <= b

Parameters
bthe other fixed point
Returns
true if this <= b

◆ operator==()

bool operator== ( const Q< M, F, true, int32_t > &  b) const
inline

this == b

Parameters
bthe other fixed point
Returns
true if this == b

◆ operator>()

bool operator> ( const Q< M, F, true, int32_t > &  b) const
inline

this > b

Parameters
bthe other fixed point
Returns
true if this > b

◆ operator>=()

bool operator>= ( const Q< M, F, true, int32_t > &  b) const
inline

this >= b

Parameters
bthe other fixed point
Returns
true if this >= b

◆ sat()

static constexpr value_type sat ( const wider_type  i)
inlinestaticconstexpr

Saturate a wider type to the current type.

Parameters
ithe wider integer type
Returns
the saturated value

◆ arm_cmsis_dsp::Q< M, F, false, uint32_t >

struct arm_cmsis_dsp::Q< M, F, false, uint32_t >
template<int M, int F>
struct arm_cmsis_dsp::Q< M, F, false, uint32_t >

Unsigned fixed point datatypes on 32 bits.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

using value_type = typename fixed_storage_type< M, F, false >::value_type
 Storage type for the value.
 
using wider_type = typename fixed_storage_type< M, F, false >::wider_type
 Storage type for the widening of the value.
 

Public Member Functions

constexpr Q ()
 Create a new zero fixed point.
 
constexpr Q (const value_type x)
 Create a new fixed point from a raw integer.
 
bool operator== (const Q &b) const
 this == b
 
bool operator!= (const Q &b) const
 this != b
 
bool operator< (const Q &b) const
 this < b
 
bool operator> (const Q &b) const
 this > b
 
bool operator<= (const Q &b) const
 this <= b
 
bool operator>= (const Q &b) const
 this >= b
 

Static Public Member Functions

static constexpr value_type sat (const wider_type i)
 Saturate a wider type to the current type.
 
static constexpr value_type convert (const float f)
 Convert a float to fixed point with saturation.
 
static constexpr Q f (const float x)
 Create a new fixed point from a float.
 
static constexpr Q one ()
 Fixed point number representing 1.
 

Data Fields

value_type v
 Storage value.
 

Static Public Attributes

static constexpr int fracBits = F
 Number of fractional bits.
 
static constexpr int mantissaBits = M
 Number of mantissa bits (without sign bit)
 
static constexpr bool isSigned = false
 Is this number representation signed.
 
static constexpr value_type maxVal = 0xFFFFFFFFL
 Maximum representable positive value.
 

Constructor & Destructor Documentation

◆ Q()

constexpr Q ( const value_type  x)
inlineexplicitconstexpr

Create a new fixed point from a raw integer.

Parameters
xthe raw integer

Member Function Documentation

◆ convert()

static constexpr value_type convert ( const float  f)
inlinestaticconstexpr

Convert a float to fixed point with saturation.

Parameters
ffloat value
Returns
the fixed point value in the storage type

◆ f()

static constexpr Q f ( const float  x)
inlinestaticconstexpr

Create a new fixed point from a float.

Parameters
xthe float
Returns
The fixed point representing the float value with saturation

◆ one()

static constexpr Q one ( )
inlinestaticconstexpr

Fixed point number representing 1.

Returns
Fixed point representing 1

◆ operator!=()

bool operator!= ( const Q< M, F, false, uint32_t > &  b) const
inline

this != b

Parameters
bthe other fixed point
Returns
true if this != b

◆ operator<()

bool operator< ( const Q< M, F, false, uint32_t > &  b) const
inline

this < b

Parameters
bthe other fixed point
Returns
true if this < b

◆ operator<=()

bool operator<= ( const Q< M, F, false, uint32_t > &  b) const
inline

this <= b

Parameters
bthe other fixed point
Returns
true if this <= b

◆ operator==()

bool operator== ( const Q< M, F, false, uint32_t > &  b) const
inline

this == b

Parameters
bthe other fixed point
Returns
true if this == b

◆ operator>()

bool operator> ( const Q< M, F, false, uint32_t > &  b) const
inline

this > b

Parameters
bthe other fixed point
Returns
true if this > b

◆ operator>=()

bool operator>= ( const Q< M, F, false, uint32_t > &  b) const
inline

this >= b

Parameters
bthe other fixed point
Returns
true if this >= b

◆ sat()

static constexpr value_type sat ( const wider_type  i)
inlinestaticconstexpr

Saturate a wider type to the current type.

Parameters
ithe wider integer type
Returns
the saturated value

◆ arm_cmsis_dsp::Q< M, F, true, int16_t >

struct arm_cmsis_dsp::Q< M, F, true, int16_t >
template<int M, int F>
struct arm_cmsis_dsp::Q< M, F, true, int16_t >

Signed fixed point datatypes on 16 bits.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

using value_type = typename fixed_storage_type< M, F, true >::value_type
 Storage type for the value.
 
using wider_type = typename fixed_storage_type< M, F, true >::wider_type
 Storage type for the widening of the value.
 

Public Member Functions

constexpr Q ()
 Create a new zero fixed point.
 
constexpr Q (const value_type x)
 Create a new fixed point from a raw integer.
 
constexpr Q (const Q< M, F, false > &other)
 Convert an unsigned fixed point to this fixed point.
 
bool operator== (const Q &b) const
 this == b
 
bool operator!= (const Q &b) const
 this != b
 
bool operator< (const Q &b) const
 this < b
 
bool operator> (const Q &b) const
 this > b
 
bool operator<= (const Q &b) const
 this <= b
 
bool operator>= (const Q &b) const
 this >= b
 
Qoperator+= (const Q other)
 this += other
 
Qoperator-= (const Q other)
 this -= other
 

Static Public Member Functions

static constexpr value_type sat (const wider_type i)
 Saturate a wider type to the current type.
 
static constexpr value_type convert (const float f)
 Convert a float to fixed point with saturation.
 
static constexpr Q f (const float x)
 Create a new fixed point from a float.
 
static constexpr Q one ()
 Fixed point number representing 1.
 

Data Fields

value_type v
 Storage value.
 

Static Public Attributes

static constexpr int fracBits = F
 Number of fractional bits.
 
static constexpr int mantissaBits = M
 Number of mantissa bits (without sign bit)
 
static constexpr bool isSigned = true
 Is this number representation signed.
 
static constexpr value_type maxVal = 0x7FFF
 Maximum representable positive value.
 
static constexpr value_type minVal = 0x8000
 Minimum representable negative value.
 

Constructor & Destructor Documentation

◆ Q() [1/2]

constexpr Q ( const value_type  x)
inlineexplicitconstexpr

Create a new fixed point from a raw integer.

Parameters
xthe raw integer

◆ Q() [2/2]

constexpr Q ( const Q< M, F, false > &  other)
inlineexplicitconstexpr

Convert an unsigned fixed point to this fixed point.

Parameters
otherThe unsigned fixed point number

Some problem may occur since the unsigned may not be representable with the less bits required for the sign representation. This convertion is not saturating.

Member Function Documentation

◆ convert()

static constexpr value_type convert ( const float  f)
inlinestaticconstexpr

Convert a float to fixed point with saturation.

Parameters
ffloat value
Returns
the fixed point value in the storage type

◆ f()

static constexpr Q f ( const float  x)
inlinestaticconstexpr

Create a new fixed point from a float.

Parameters
xthe float
Returns
The fixed point representing the float value with saturation

◆ one()

static constexpr Q one ( )
inlinestaticconstexpr

Fixed point number representing 1.

Returns
Fixed point representing 1

◆ operator!=()

bool operator!= ( const Q< M, F, true, int16_t > &  b) const
inline

this != b

Parameters
bthe other fixed point
Returns
true if this != b

◆ operator+=()

Q & operator+= ( const Q< M, F, true, int16_t >  other)
inline

this += other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator-=()

Q & operator-= ( const Q< M, F, true, int16_t >  other)
inline

this -= other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator<()

bool operator< ( const Q< M, F, true, int16_t > &  b) const
inline

this < b

Parameters
bthe other fixed point
Returns
true if this < b

◆ operator<=()

bool operator<= ( const Q< M, F, true, int16_t > &  b) const
inline

this <= b

Parameters
bthe other fixed point
Returns
true if this <= b

◆ operator==()

bool operator== ( const Q< M, F, true, int16_t > &  b) const
inline

this == b

Parameters
bthe other fixed point
Returns
true if this == b

◆ operator>()

bool operator> ( const Q< M, F, true, int16_t > &  b) const
inline

this > b

Parameters
bthe other fixed point
Returns
true if this > b

◆ operator>=()

bool operator>= ( const Q< M, F, true, int16_t > &  b) const
inline

this >= b

Parameters
bthe other fixed point
Returns
true if this >= b

◆ sat()

static constexpr value_type sat ( const wider_type  i)
inlinestaticconstexpr

Saturate a wider type to the current type.

Parameters
ithe wider integer type
Returns
the saturated value

◆ arm_cmsis_dsp::Q< M, F, false, uint16_t >

struct arm_cmsis_dsp::Q< M, F, false, uint16_t >
template<int M, int F>
struct arm_cmsis_dsp::Q< M, F, false, uint16_t >

Unsigned fixed point datatypes on 16 bits.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

using value_type = typename fixed_storage_type< M, F, false >::value_type
 Storage type for the value.
 
using wider_type = typename fixed_storage_type< M, F, false >::wider_type
 Storage type for the widening of the value.
 

Public Member Functions

constexpr Q ()
 Create a new zero fixed point.
 
constexpr Q (const value_type x)
 Create a new fixed point from a raw integer.
 
bool operator== (const Q &b) const
 this == b
 
bool operator!= (const Q &b) const
 this != b
 
bool operator< (const Q &b) const
 this < b
 
bool operator> (const Q &b) const
 this > b
 
bool operator<= (const Q &b) const
 this <= b
 
bool operator>= (const Q &b) const
 this >= b
 
Qoperator+= (const Q other)
 this += other
 

Static Public Member Functions

static constexpr value_type sat (const wider_type i)
 Saturate a wider type to the current type.
 
static constexpr value_type convert (const float f)
 Convert a float to fixed point with saturation.
 
static constexpr Q f (const float x)
 Create a new fixed point from a float.
 
static constexpr Q one ()
 Fixed point number representing 1.
 

Data Fields

value_type v
 Storage value.
 

Static Public Attributes

static constexpr int fracBits = F
 Number of fractional bits.
 
static constexpr int mantissaBits = M
 Number of mantissa bits (without sign bit)
 
static constexpr bool isSigned = false
 Is this number representation signed.
 
static constexpr value_type maxVal = 0xFFFF
 Maximum representable positive value.
 

Constructor & Destructor Documentation

◆ Q()

constexpr Q ( const value_type  x)
inlineexplicitconstexpr

Create a new fixed point from a raw integer.

Parameters
xthe raw integer

Member Function Documentation

◆ convert()

static constexpr value_type convert ( const float  f)
inlinestaticconstexpr

Convert a float to fixed point with saturation.

Parameters
ffloat value
Returns
the fixed point value in the storage type

◆ f()

static constexpr Q f ( const float  x)
inlinestaticconstexpr

Create a new fixed point from a float.

Parameters
xthe float
Returns
The fixed point representing the float value with saturation

◆ one()

static constexpr Q one ( )
inlinestaticconstexpr

Fixed point number representing 1.

Returns
Fixed point representing 1

◆ operator!=()

bool operator!= ( const Q< M, F, false, uint16_t > &  b) const
inline

this != b

Parameters
bthe other fixed point
Returns
true if this != b

◆ operator+=()

Q & operator+= ( const Q< M, F, false, uint16_t >  other)
inline

this += other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator<()

bool operator< ( const Q< M, F, false, uint16_t > &  b) const
inline

this < b

Parameters
bthe other fixed point
Returns
true if this < b

◆ operator<=()

bool operator<= ( const Q< M, F, false, uint16_t > &  b) const
inline

this <= b

Parameters
bthe other fixed point
Returns
true if this <= b

◆ operator==()

bool operator== ( const Q< M, F, false, uint16_t > &  b) const
inline

this == b

Parameters
bthe other fixed point
Returns
true if this == b

◆ operator>()

bool operator> ( const Q< M, F, false, uint16_t > &  b) const
inline

this > b

Parameters
bthe other fixed point
Returns
true if this > b

◆ operator>=()

bool operator>= ( const Q< M, F, false, uint16_t > &  b) const
inline

this >= b

Parameters
bthe other fixed point
Returns
true if this >= b

◆ sat()

static constexpr value_type sat ( const wider_type  i)
inlinestaticconstexpr

Saturate a wider type to the current type.

Parameters
ithe wider integer type
Returns
the saturated value

◆ arm_cmsis_dsp::Q< M, F, true, int8_t >

struct arm_cmsis_dsp::Q< M, F, true, int8_t >
template<int M, int F>
struct arm_cmsis_dsp::Q< M, F, true, int8_t >

Signed fixed point datatypes on 8 bits.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

using value_type = typename fixed_storage_type< M, F, true >::value_type
 Storage type for the value.
 
using wider_type = typename fixed_storage_type< M, F, true >::wider_type
 Storage type for the widening of the value.
 

Public Member Functions

constexpr Q ()
 Create a new zero fixed point.
 
constexpr Q (const value_type x)
 Create a new fixed point from a raw integer.
 
constexpr Q (const Q< M, F, false > &other)
 Convert an unsigned fixed point to this fixed point.
 
bool operator== (const Q &b) const
 this == b
 
bool operator!= (const Q &b) const
 this != b
 
bool operator< (const Q &b) const
 this < b
 
bool operator> (const Q &b) const
 this > b
 
bool operator<= (const Q &b) const
 this <= b
 
bool operator>= (const Q &b) const
 this >= b
 
Qoperator+= (const Q other)
 this += other
 
Qoperator-= (const Q other)
 this -= other
 

Static Public Member Functions

static constexpr value_type sat (const wider_type i)
 Saturate a wider type to the current type.
 
static constexpr value_type convert (const float f)
 Convert a float to fixed point with saturation.
 
static constexpr Q f (const float x)
 Create a new fixed point from a float.
 
static constexpr Q one ()
 Fixed point number representing 1.
 

Data Fields

value_type v
 Storage value.
 

Static Public Attributes

static constexpr int fracBits = F
 Number of fractional bits.
 
static constexpr int mantissaBits = M
 Number of mantissa bits (without sign bit)
 
static constexpr bool isSigned = true
 Is this number representation signed.
 
static constexpr value_type maxVal = 0x7F
 Maximum representable positive value.
 
static constexpr value_type minVal = 0x80
 Minimum representable negative value.
 

Constructor & Destructor Documentation

◆ Q() [1/2]

constexpr Q ( const value_type  x)
inlineexplicitconstexpr

Create a new fixed point from a raw integer.

Parameters
xthe raw integer

◆ Q() [2/2]

constexpr Q ( const Q< M, F, false > &  other)
inlineexplicitconstexpr

Convert an unsigned fixed point to this fixed point.

Parameters
otherThe unsigned fixed point number

Some problem may occur since the unsigned may not be representable with the less bits required for the sign representation. This convertion is not saturating.

Member Function Documentation

◆ convert()

static constexpr value_type convert ( const float  f)
inlinestaticconstexpr

Convert a float to fixed point with saturation.

Parameters
ffloat value
Returns
the fixed point value in the storage type

◆ f()

static constexpr Q f ( const float  x)
inlinestaticconstexpr

Create a new fixed point from a float.

Parameters
xthe float
Returns
The fixed point representing the float value with saturation

◆ one()

static constexpr Q one ( )
inlinestaticconstexpr

Fixed point number representing 1.

Returns
Fixed point representing 1

◆ operator!=()

bool operator!= ( const Q< M, F, true, int8_t > &  b) const
inline

this != b

Parameters
bthe other fixed point
Returns
true if this != b

◆ operator+=()

Q & operator+= ( const Q< M, F, true, int8_t >  other)
inline

this += other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator-=()

Q & operator-= ( const Q< M, F, true, int8_t >  other)
inline

this -= other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator<()

bool operator< ( const Q< M, F, true, int8_t > &  b) const
inline

this < b

Parameters
bthe other fixed point
Returns
true if this < b

◆ operator<=()

bool operator<= ( const Q< M, F, true, int8_t > &  b) const
inline

this <= b

Parameters
bthe other fixed point
Returns
true if this <= b

◆ operator==()

bool operator== ( const Q< M, F, true, int8_t > &  b) const
inline

this == b

Parameters
bthe other fixed point
Returns
true if this == b

◆ operator>()

bool operator> ( const Q< M, F, true, int8_t > &  b) const
inline

this > b

Parameters
bthe other fixed point
Returns
true if this > b

◆ operator>=()

bool operator>= ( const Q< M, F, true, int8_t > &  b) const
inline

this >= b

Parameters
bthe other fixed point
Returns
true if this >= b

◆ sat()

static constexpr value_type sat ( const wider_type  i)
inlinestaticconstexpr

Saturate a wider type to the current type.

Parameters
ithe wider integer type
Returns
the saturated value

◆ arm_cmsis_dsp::Q< M, F, false, uint8_t >

struct arm_cmsis_dsp::Q< M, F, false, uint8_t >
template<int M, int F>
struct arm_cmsis_dsp::Q< M, F, false, uint8_t >

Unsigned fixed point datatypes on 8 bits.

Template Parameters
MNumber of bits for mantissa (without sign bit)
FNumber of bits for fractional part

Public Types

using value_type = typename fixed_storage_type< M, F, false >::value_type
 Storage type for the value.
 
using wider_type = typename fixed_storage_type< M, F, false >::wider_type
 Storage type for the widening of the value.
 

Public Member Functions

constexpr Q ()
 Create a new zero fixed point.
 
constexpr Q (const value_type x)
 Create a new fixed point from a raw integer.
 
bool operator== (const Q &b) const
 this == b
 
bool operator!= (const Q &b) const
 this != b
 
bool operator< (const Q &b) const
 this < b
 
bool operator> (const Q &b) const
 this > b
 
bool operator<= (const Q &b) const
 this <= b
 
bool operator>= (const Q &b) const
 this >= b
 
Qoperator+= (const Q other)
 this += other
 

Static Public Member Functions

static constexpr value_type sat (const wider_type i)
 Saturate a wider type to the current type.
 
static constexpr value_type convert (const float f)
 Convert a float to fixed point with saturation.
 
static constexpr Q f (const float x)
 Create a new fixed point from a float.
 
static constexpr Q one ()
 Fixed point number representing 1.
 

Data Fields

value_type v
 Storage value.
 

Static Public Attributes

static constexpr int fracBits = F
 Number of fractional bits.
 
static constexpr int mantissaBits = M
 Number of mantissa bits (without sign bit)
 
static constexpr bool isSigned = false
 Is this number representation signed.
 
static constexpr value_type maxVal = 0xFF
 Maximum representable positive value.
 

Constructor & Destructor Documentation

◆ Q()

constexpr Q ( const value_type  x)
inlineexplicitconstexpr

Create a new fixed point from a raw integer.

Parameters
xthe raw integer

Member Function Documentation

◆ convert()

static constexpr value_type convert ( const float  f)
inlinestaticconstexpr

Convert a float to fixed point with saturation.

Parameters
ffloat value
Returns
the fixed point value in the storage type

◆ f()

static constexpr Q f ( const float  x)
inlinestaticconstexpr

Create a new fixed point from a float.

Parameters
xthe float
Returns
The fixed point representing the float value with saturation

◆ one()

static constexpr Q one ( )
inlinestaticconstexpr

Fixed point number representing 1.

Returns
Fixed point representing 1

◆ operator!=()

bool operator!= ( const Q< M, F, false, uint8_t > &  b) const
inline

this != b

Parameters
bthe other fixed point
Returns
true if this != b

◆ operator+=()

Q & operator+= ( const Q< M, F, false, uint8_t >  other)
inline

this += other

Parameters
otherthe other fixed point
Returns
true if this += other

◆ operator<()

bool operator< ( const Q< M, F, false, uint8_t > &  b) const
inline

this < b

Parameters
bthe other fixed point
Returns
true if this < b

◆ operator<=()

bool operator<= ( const Q< M, F, false, uint8_t > &  b) const
inline

this <= b

Parameters
bthe other fixed point
Returns
true if this <= b

◆ operator==()

bool operator== ( const Q< M, F, false, uint8_t > &  b) const
inline

this == b

Parameters
bthe other fixed point
Returns
true if this == b

◆ operator>()

bool operator> ( const Q< M, F, false, uint8_t > &  b) const
inline

this > b

Parameters
bthe other fixed point
Returns
true if this > b

◆ operator>=()

bool operator>= ( const Q< M, F, false, uint8_t > &  b) const
inline

this >= b

Parameters
bthe other fixed point
Returns
true if this >= b

◆ sat()

static constexpr value_type sat ( const wider_type  i)
inlinestaticconstexpr

Saturate a wider type to the current type.

Parameters
ithe wider integer type
Returns
the saturated value

◆ arm_cmsis_dsp::FixedCastShift< M, FD, FS, S,(FD >FS)>

struct arm_cmsis_dsp::FixedCastShift< M, FD, FS, S,(FD >FS)>
template<int M, int FD, int FS, bool S>
struct arm_cmsis_dsp::FixedCastShift< M, FD, FS, S,(FD >FS)>

Changed fractional representation of a fixed point number using a shift.

Template Parameters
MNumber of mantissa bits for the fixed point number
FDNumber of fractional bits for the destination fixed point number
FSNumber of fractional bits for the source fixed point number
SIs the fixed point number using a signed representation
Parameters
srcThe fixed point number
Returns
return the fixed point number with different fractional part format

Only applies if FD > FS

◆ arm_cmsis_dsp::FixedCastShift< M, FD, FS, S,(FD< FS)>

struct arm_cmsis_dsp::FixedCastShift< M, FD, FS, S,(FD< FS)>
template<int M, int FD, int FS, bool S>
struct arm_cmsis_dsp::FixedCastShift< M, FD, FS, S,(FD< FS)>

Changed fractional representation of a fixed point number using a shift.

Template Parameters
MNumber of mantissa bits for the fixed point number
FDNumber of fractional bits for the destination fixed point number
FSNumber of fractional bits for the source fixed point number
SIs the fixed point number using a signed representation
Parameters
srcThe fixed point number
Returns
return the fixed point number with different fractional part format

Only applies if FD < FS

◆ arm_cmsis_dsp::Accumulate

struct arm_cmsis_dsp::Accumulate
template<int MD, int MS, int F, bool S, bool = true>
struct arm_cmsis_dsp::Accumulate< MD, MS, F, S, bool >

Accumulation without saturation.

Template Parameters
MDNumber of mantissa bits for the destination fixed point number
MSNumber of mantissa bits for the source fixed point number
FNumber of fractional bits for fixed point number
SIs the fixed point number using a signed representation

◆ arm_cmsis_dsp::Accumulate< MD, MS, F, S, true >

struct arm_cmsis_dsp::Accumulate< MD, MS, F, S, true >
template<int MD, int MS, int F, bool S>
struct arm_cmsis_dsp::Accumulate< MD, MS, F, S, true >

Accumulation without saturation.

Template Parameters
MDNumber of mantissa bits for the destination fixed point number
MSNumber of mantissa bits for the source fixed point number
FNumber of fractional bits for fixed point number
SIs the fixed point number using a signed representation

Static Public Member Functions

static Q< MD, F, S > acc (const Q< MD, F, S > &a, const Q< MS, F, S > &b)
 Accumulation without saturation.
 

Member Function Documentation

◆ acc()

static Q< MD, F, S > acc ( const Q< MD, F, S > &  a,
const Q< MS, F, S > &  b 
)
inlinestatic

Accumulation without saturation.

Parameters
[in]afirst fixed point number
[in]bsecond fixed point number
Returns
The sum of both fixed point number with more matissa bits.

Function Documentation

◆ accumulate()

Q< MD, F, S > accumulate ( const Q< MD, F, S > &  a,
const Q< MS, F, S > &  b 
)
inline

Accumulate without saturation.

Parameters
[in]aFirst fixed point number
[in]bSecond fixed point number
Template Parameters
MDNumber of mantissa bits for destination
MSNumber of mantissa bits fro source
FNumber of fractional bits
SIs the representation signed
Returns
Sum of two numbers without saturation and using the destination number of mantissa bits

◆ add()

Q< M, F, S > add ( const Q< M, F, S > &  a,
const Q< M, F, S > &  b 
)
inline

Add two fixed point numbers without saturation.

Template Parameters
MNumber of mantissa bits for the fixed point number
FNumber of fractional bits for the fixed point number
SIs the fixed point number using a signed representation
Parameters
aFirst fixed point number
bSecond fixed point number
Returns
return the sum without saturation

◆ mult()

Q< MA+MB+1, FA+FB, SA||SB > mult ( const Q< MA, FA, SA > &  a,
const Q< MB, FB, SB > &  b 
)
inline

Multiplication of two fixed point numbers A and B.

Template Parameters
MANumber of mantissa bits for A
FANumber of fractional bits for A
MBNumber of mantissa bits for B
FBNumber of fractional bits for B
SAIs A using a signed representation
SBIs B using a signed representation
Parameters
aFirst fixed point number
bSecond fixed point number
Returns
return the product of the two fixed point (and use adapted type)

◆ operator!=()

bool operator!= ( const Q< M, F >  a,
const Q< M, F >  b 
)
inline

Inequality operator.

Parameters
[in]aFirst value
[in]bSecond value
Template Parameters
MNumber of mantissa bits
FNumber of fractional bits
Returns
The result of the inequality

◆ operator""_q15()

constexpr Q15 operator""_q15 ( long double  x)
constexpr

q15 literal

Parameters
xlong double value
Returns
Q15 value

You can write

Q15 b = 0.4_q15;

The float is converted to Q15 at build time.

◆ operator""_q31()

constexpr Q31 operator""_q31 ( long double  x)
constexpr

q31 literal

Parameters
xlong double value
Returns
Q31 value

You can write

Q31 b = 0.4_q31;

The float is converted to Q31 at build time.

◆ operator""_q63()

constexpr Q63 operator""_q63 ( long double  x)
constexpr

q63 literal

Parameters
xlong double value
Returns
Q63 value

You can write

Q63 b = 0.4_q63;

The float is converted to Q63 at build time.

◆ operator""_q7()

constexpr Q7 operator""_q7 ( long double  x)
constexpr

q7 literal

Parameters
xlong double value
Returns
Q7 value

You can write

Q7 b = 0.4_q7;

The float is converted to Q7 at build time.

◆ operator*() [1/3]

Q15 operator* ( const Q15 a,
const Q15 b 
)
inline

Multiplication operator.

Parameters
[in]aFirst value
[in]bSecond value
Returns
The result of the multiplication with saturation

◆ operator*() [2/3]

Q31 operator* ( const Q31 a,
const Q31 b 
)
inline

Multiplication operator.

Parameters
[in]aFirst value
[in]bSecond value
Returns
The result of the multiplication with saturation

◆ operator*() [3/3]

Q7 operator* ( const Q7 a,
const Q7 b 
)
inline

Multiplication operator.

Parameters
[in]aFirst value
[in]bSecond value
Returns
The result of the multiplication with saturation

◆ operator+() [1/2]

Q< M, F, S > operator+ ( const Q< M, F, S > &  a)
inline

No op operator.

Parameters
[in]aFixed point number
Template Parameters
MNumber of mantissa bits
FNumber of fractional bits
SIs the representation signed
Returns
The result of the addition

◆ operator+() [2/2]

Q< M, F, S > operator+ ( const Q< M, F, S > &  a,
const Q< M, F, S > &  b 
)
inline

Add two fixed point numbers with saturation.

Template Parameters
MNumber of mantissa bits for the fixed point number
FNumber of fractional bits for the fixed point number
SIs the fixed point number using a signed representation
Parameters
aFirst fixed point number
bSecond fixed point number
Returns
return the sum with saturation (if supported by the datatype)

◆ operator-() [1/2]

Q< M, F, S > operator- ( const Q< M, F, S > &  a)
inline

Negate a fixed point number with saturation.

Template Parameters
MNumber of mantissa bits for the fixed point number
FNumber of fractional bits for the fixed point number
SIs the fixed point number using a signed representation
Parameters
aFirst fixed point number
Returns
return negation with saturation (if supported by the datatype)

◆ operator-() [2/2]

Q< M, F, S > operator- ( const Q< M, F, S > &  a,
const Q< M, F, S > &  b 
)
inline

Subtract two fixed point numbers with saturation.

Template Parameters
MNumber of mantissa bits for the fixed point number
FNumber of fractional bits for the fixed point number
SIs the fixed point number using a signed representation
Parameters
aFirst fixed point number
bSecond fixed point number
Returns
return the subtraction with saturation (if supported by the datatype)

◆ operator/()

Q< M, F, S > operator/ ( const Q< M, F, S >  a,
const int32_t  b 
)
inline

Division operator.

Parameters
[in]aFirst fixed point value
[in]bInteger
Template Parameters
MNumber of mantissa bits
FNumber of fractional bits
SIs representation signed
Returns
The result of the division

◆ operator<()

bool operator< ( const Q< M, F > &  a,
const Q< M, F > &  b 
)
inline

Less-than comparison operator.

Parameters
[in]aFirst value
[in]bSecond value
Template Parameters
MNumber of mantissa bits
FNumber of fractional bits
Returns
The result of the less-than comparison

◆ operator<<()

Q< M+N, F, S > operator<< ( const Q< M, F, S > &  a,
std::integral_constant< int, N >   
)
inlinenoexcept

Shift left a fixed point number with a shift known at build time.

Template Parameters
MNumber of mantissa bits for the fixed point number
FNumber of fractional bits for the fixed point number
SIs the fixed point number using a signed representation
Parameters
aFirst fixed point number
Returns
return the shifted fixed point number

◆ operator<=()

bool operator<= ( const Q< M, F > &  a,
const Q< M, F > &  b 
)
inline

Less-than-or-equal comparison operator.

Parameters
[in]aFirst value
[in]bSecond value
Template Parameters
MNumber of mantissa bits
FNumber of fractional bits
Returns
The result of the less-than-or-equal comparison

◆ operator==()

bool operator== ( const Q< M, F >  a,
const Q< M, F >  b 
)
inline

Equality operator.

Parameters
[in]aFirst value
[in]bSecond value
Template Parameters
MNumber of mantissa bits
FNumber of fractional bits
Returns
The result of the equality

◆ operator>()

bool operator> ( const Q< M, F > &  a,
const Q< M, F > &  b 
)
inline

Greater-than comparison operator.

Parameters
[in]aFirst value
[in]bSecond value
Template Parameters
MNumber of mantissa bits
FNumber of fractional bits
Returns
The result of the greater-than comparison

◆ operator>=()

bool operator>= ( const Q< M, F > &  a,
const Q< M, F > &  b 
)
inline

Greater-than-or-equal comparison operator.

Parameters
[in]aFirst value
[in]bSecond value
Template Parameters
MNumber of mantissa bits
FNumber of fractional bits
Returns
The result of the greater-than-or-equal comparison

◆ operator>>()

Q< M, F, S > operator>> ( const Q< M, F, S > &  a,
std::integral_constant< int, N >   
)
inlinenoexcept

Shift right a fixed point number with a shift known at build time.

Template Parameters
MNumber of mantissa bits for the fixed point number
FNumber of fractional bits for the fixed point number
SIs the fixed point number using a signed representation
Parameters
aFirst fixed point number
Returns
return the shifted fixed point number

◆ saturate() [1/2]

Q< MD, F, false > saturate ( const Q< MS, F, false > &  src,
typename std::enable_if<(MD< MS) &&((MD+F)< 31)>::type *  = nullptr 
)
inline

Saturate an unsigned fixed point number.

Template Parameters
MDNumber of mantissa bits for the destination fixed point number
MSNumber of mantissa bits for the source fixed point number
SIs the fixed point number using a signed representation
Parameters
srcThe fixed point number
Returns
return the saturated fixed point number

Only applies if the number is unsigned, the representation requires less than 31 bits (since there is no saturating instruction for 64 bits) and if destination has less mantissa bits.

If destination has more or equal number of mantissa bits then it does not make sense to saturate.

◆ saturate() [2/2]

Q< MD, F, true > saturate ( const Q< MS, F, true > &  src,
typename std::enable_if<(MD< MS) &&((MD+F)< 31)>::type *  = nullptr 
)
inline

Saturate a signed fixed point number.

Template Parameters
MDNumber of mantissa bits for the destination fixed point number
MSNumber of mantissa bits for the source fixed point number
SIs the fixed point number using a signed representation
Parameters
srcFirst fixed point number
Returns
return the saturated fixed point number

Only applies if the number is signed, the representation requires less than 32 bits (since there is no saturating instruction for 64 bits) and if destination has less mantissa bits.

If destination has more or equal number of mantissa bits then it does not make sense to saturate.

◆ sub()

Q< M, F, S > sub ( const Q< M, F, S > &  a,
const Q< M, F, S > &  b 
)
inline

Subtract two fixed point numbers without saturation.

Template Parameters
MNumber of mantissa bits for the fixed point number
FNumber of fractional bits for the fixed point number
SIs the fixed point number using a signed representation
Parameters
aFirst fixed point number
bSecond fixed point number
Returns
return the subtraction without saturation

◆ test16()

constexpr bool test16 ( const int  M,
const int  F,
const int  S 
)
constexpr

Function to identify the template for fixed number representable on 16 bits.

Parameters
Mnumber of mantissa bit (without sign bit)
Fnumber of fractional bits
Ssign or unsigned
Returns
True if the template must be selected

◆ test32()

constexpr bool test32 ( const int  M,
const int  F,
const int  S 
)
constexpr

Function to identify the template for fixed number representable on 32 bits.

Parameters
Mnumber of mantissa bit (without sign bit)
Fnumber of fractional bits
Ssign or unsigned
Returns
True if the template must be selected

◆ test64()

constexpr bool test64 ( const int  M,
const int  F,
const int  S 
)
constexpr

Function to identify the template for fixed number representable on 64 bits.

Parameters
Mnumber of mantissa bit (without sign bit)
Fnumber of fractional bits
Ssign or unsigned
Returns
True if the template must be selected

◆ test8()

constexpr bool test8 ( const int  M,
const int  F,
const int  S 
)
constexpr

Function to identify the template for fixed number representable on 8 bits.

Parameters
Mnumber of mantissa bit (without sign bit)
Fnumber of fractional bits
Ssign or unsigned
Returns
True if the template must be selected

◆ toFrac()

Q< M, FD, S > toFrac ( const Q< M, FS, S > &  src)
inline

Convert between different fractional part formats.

Template Parameters
MNumber of mantissa bits for the fixed point number
FDNumber of fractional bits for the destination fixed point number
FSNumber of fractional bits for the source fixed point number
SIs the fixed point number using a signed representation
Parameters
srcThe fixed point number
Returns
return the fixed point number with different fractional part format