Special library for primitive IEEE 754 floating point handling without dragging all float support along.
More...
#include <stdint.h>
#include <stdbool.h>
Go to the source code of this file.
|
typedef uint32_t | f32_t |
| 32 bit representation for float. More...
|
|
typedef uint64_t | f64_t |
| 642 bit representation for float
|
|
|
int32_t | fltToI32 (f32_t value, uint32_t multiplier) |
| This takes a f32_t IEEE 754 single precision floating point, and converts it to a multiplied integer. More...
|
|
uint32_t | fltFrac (f32_t value, int decimals) |
| Returns the fractional part of the floating point with the specified number of decimals. More...
|
|
int32_t | fltInt (f32_t value) |
| Returns the integer part of the floating point value. More...
|
|
f32_t | fltFromI16 (int16_t val, int fBits) |
| Takes an integer value and converts it to a float. More...
|
|
Special library for primitive IEEE 754 floating point handling without dragging all float support along.
Definition in file float.h.
32 bit representation for float.
Definition at line 30 of file float.h.
uint32_t fltFrac |
( |
f32_t |
value, |
|
|
int |
decimals |
|
) |
| |
Returns the fractional part of the floating point with the specified number of decimals.
- Parameters
-
- Returns
Definition at line 96 of file float.c.
f32_t fltFromI16 |
( |
int16_t |
val, |
|
|
int |
fBits |
|
) |
| |
Takes an integer value and converts it to a float.
- Parameters
-
value | The value |
scaling | The number of fractional bits |
- Returns
- A float
Definition at line 122 of file float.c.
int32_t fltInt |
( |
f32_t |
value | ) |
|
Returns the integer part of the floating point value.
- Parameters
-
- Returns
Definition at line 102 of file float.c.
int32_t fltToI32 |
( |
f32_t |
value, |
|
|
uint32_t |
multiplier |
|
) |
| |
This takes a f32_t IEEE 754 single precision floating point, and converts it to a multiplied integer.
E.g. if you supply 3.75 with multiplier 100 the resulting integer will be 375.
- Note
- Rounding has not yet been applied.
- Parameters
-
value | The floating point value |
multiplier | The value to multiply with before chopping of the decimal part |
applySign | Whether or not to apply the sign. |
- Returns
- The integer representing the floating point value.
Definition at line 90 of file float.c.