FastLED 3.9.7
Loading...
Searching...
No Matches
Float-to-Fixed and Fixed-to-Float Conversions

Detailed Description

Functions to convert between floating point and fixed point types.

Note
Anything involving a "float" on AVR will be slower.

Functions

LIB8STATIC float sfract15ToFloat (sfract15 y)
 Conversion from 16-bit fixed point (sfract15) to IEEE754 32-bit float.
 
LIB8STATIC sfract15 floatToSfract15 (float f)
 Conversion from IEEE754 float in the range (-1,1) to 16-bit fixed point (sfract15).
 

Function Documentation

◆ floatToSfract15()

LIB8STATIC sfract15 floatToSfract15 ( float f)

Conversion from IEEE754 float in the range (-1,1) to 16-bit fixed point (sfract15).

Note
The extremes of one and negative one are NOT representable! The representable range is 0.99996948242 to -0.99996948242, in steps of 0.00003051757.

Definition at line 406 of file lib8tion.h.

◆ sfract15ToFloat()

LIB8STATIC float sfract15ToFloat ( sfract15 y)

Conversion from 16-bit fixed point (sfract15) to IEEE754 32-bit float.

Definition at line 398 of file lib8tion.h.