FastLED 3.9.3
Loading...
Searching...
No Matches
Fixed-Point Fractional Types.

Detailed Description

Types for storing fractional data.

Example: if a fract8 has the value "64", that should be interpreted as 64/256ths, or one-quarter.

accumXY types should be interpreted as X bits of integer, and Y bits of fraction.
E.g., accum88 has 8 bits of int, 8 bits of fraction

Classes

union  IEEE754binary32_t
 typedef for IEEE754 "binary32" float type internals More...
 
class  qfx< T, F, I >
 Template class for representing fractional ints. More...
 

Typedefs

typedef uint8_t fract8
 ANSI: unsigned short _Fract.
 
typedef int8_t sfract7
 ANSI: signed short _Fract.
 
typedef uint16_t fract16
 ANSI: unsigned _Fract.
 
typedef int32_t sfract31
 ANSI: signed long _Fract. 31 bits int, 1 bit fraction.
 
typedef uint32_t fract32
 ANSI: unsigned long _Fract. 32 bits int, 32 bits fraction.
 
typedef int16_t sfract15
 ANSI: signed _Fract.
 
typedef uint16_t accum88
 ANSI: unsigned short _Accum. 8 bits int, 8 bits fraction.
 
typedef int16_t saccum78
 ANSI: signed short _Accum. 7 bits int, 8 bits fraction.
 
typedef uint32_t accum1616
 ANSI: signed _Accum. 16 bits int, 16 bits fraction.
 
typedef int32_t saccum1516
 ANSI: signed _Accum. 15 bits int, 16 bits fraction.
 
typedef uint16_t accum124
 no direct ANSI counterpart. 12 bits int, 4 bits fraction
 
typedef int32_t saccum114
 no direct ANSI counterpart. 1 bit int, 14 bits fraction
 
typedef qfx< uint8_t, 4, 4 > q44
 A 4.4 integer (4 bits integer, 4 bits fraction)
 
typedef qfx< uint8_t, 6, 2 > q62
 A 6.2 integer (6 bits integer, 2 bits fraction)
 
typedef qfx< uint16_t, 8, 8 > q88
 A 8.8 integer (8 bits integer, 8 bits fraction)
 
typedef qfx< uint16_t, 12, 4 > q124
 A 12.4 integer (12 bits integer, 4 bits fraction)
 

Functions

 qfx< T, F, I >::qfx (float fx)
 Constructor, storing a float as a fractional int.
 
 qfx< T, F, I >::qfx (uint8_t _i, uint8_t _f)
 Constructor, storing a fractional int directly.
 
uint32_t qfx< T, F, I >::operator* (uint32_t v)
 Multiply the fractional int by a value.
 
uint16_t qfx< T, F, I >::operator* (uint16_t v)
 Multiply the fractional int by a value.
 
int32_t qfx< T, F, I >::operator* (int32_t v)
 Multiply the fractional int by a value.
 
int16_t qfx< T, F, I >::operator* (int16_t v)
 Multiply the fractional int by a value.
 

Typedef Documentation

◆ accum124

typedef uint16_t accum124

no direct ANSI counterpart. 12 bits int, 4 bits fraction

Definition at line 56 of file types.h.

◆ accum1616

typedef uint32_t accum1616

ANSI: signed _Accum. 16 bits int, 16 bits fraction.

Definition at line 54 of file types.h.

◆ accum88

typedef uint16_t accum88

ANSI: unsigned short _Accum. 8 bits int, 8 bits fraction.

Definition at line 52 of file types.h.

◆ fract16

typedef uint16_t fract16

ANSI: unsigned _Fract.

Range is 0 to 0.99998474121 in steps of 0.00001525878.
Should be interpreted as unsigned 65536ths.

Definition at line 40 of file types.h.

◆ fract32

typedef uint32_t fract32

ANSI: unsigned long _Fract. 32 bits int, 32 bits fraction.

Definition at line 44 of file types.h.

◆ fract8

typedef uint8_t fract8

ANSI: unsigned short _Fract.

Range is 0 to 0.99609375 in steps of 0.00390625.
Should be interpreted as unsigned 256ths.

Definition at line 30 of file types.h.

◆ q124

typedef qfx<uint16_t, 12,4> q124

A 12.4 integer (12 bits integer, 4 bits fraction)

Definition at line 51 of file qfx.h.

◆ q44

typedef qfx<uint8_t, 4,4> q44

A 4.4 integer (4 bits integer, 4 bits fraction)

Definition at line 45 of file qfx.h.

◆ q62

typedef qfx<uint8_t, 6,2> q62

A 6.2 integer (6 bits integer, 2 bits fraction)

Definition at line 47 of file qfx.h.

◆ q88

typedef qfx<uint16_t, 8,8> q88

A 8.8 integer (8 bits integer, 8 bits fraction)

Definition at line 49 of file qfx.h.

◆ saccum114

typedef int32_t saccum114

no direct ANSI counterpart. 1 bit int, 14 bits fraction

Definition at line 57 of file types.h.

◆ saccum1516

typedef int32_t saccum1516

ANSI: signed _Accum. 15 bits int, 16 bits fraction.

Definition at line 55 of file types.h.

◆ saccum78

typedef int16_t saccum78

ANSI: signed short _Accum. 7 bits int, 8 bits fraction.

Definition at line 53 of file types.h.

◆ sfract15

typedef int16_t sfract15

ANSI: signed _Fract.

Range is -0.99996948242 to 0.99996948242 in steps of 0.00003051757.
Should be interpreted as signed 32768ths.

Definition at line 49 of file types.h.

◆ sfract31

typedef int32_t sfract31

ANSI: signed long _Fract. 31 bits int, 1 bit fraction.

Definition at line 42 of file types.h.

◆ sfract7

typedef int8_t sfract7

ANSI: signed short _Fract.

Range is -0.9921875 to 0.9921875 in steps of 0.0078125.
Should be interpreted as signed 128ths.

Definition at line 35 of file types.h.

Function Documentation

◆ operator*() [1/4]

template<class T , int F, int I>
int16_t qfx< T, F, I >::operator* ( int16_t v)
inline

Multiply the fractional int by a value.

Definition at line 29 of file qfx.h.

◆ operator*() [2/4]

template<class T , int F, int I>
int32_t qfx< T, F, I >::operator* ( int32_t v)
inline

Multiply the fractional int by a value.

Definition at line 27 of file qfx.h.

◆ operator*() [3/4]

template<class T , int F, int I>
uint16_t qfx< T, F, I >::operator* ( uint16_t v)
inline

Multiply the fractional int by a value.

Definition at line 25 of file qfx.h.

◆ operator*() [4/4]

template<class T , int F, int I>
uint32_t qfx< T, F, I >::operator* ( uint32_t v)
inline

Multiply the fractional int by a value.

Definition at line 23 of file qfx.h.

◆ qfx() [1/2]

template<class T , int F, int I>
qfx< T, F, I >::qfx ( float fx)
inline

Constructor, storing a float as a fractional int.

Definition at line 18 of file qfx.h.

◆ qfx() [2/2]

template<class T , int F, int I>
qfx< T, F, I >::qfx ( uint8_t _i,
uint8_t _f )
inline

Constructor, storing a fractional int directly.

Definition at line 20 of file qfx.h.