KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
float.h File Reference

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.

Macros

#define FLT2DU(VAL, DEC)   fltInt(VAL), fltFrac(VAL, DEC)
 

Typedefs

typedef uint32_t f32_t
 32 bit representation for float. More...
 
typedef uint64_t f64_t
 642 bit representation for float
 

Functions

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...
 

Detailed Description

Special library for primitive IEEE 754 floating point handling without dragging all float support along.

Definition in file float.h.

Typedef Documentation

typedef uint32_t f32_t

32 bit representation for float.

Definition at line 30 of file float.h.

Function Documentation

uint32_t fltFrac ( f32_t  value,
int  decimals 
)

Returns the fractional part of the floating point with the specified number of decimals.

Parameters
value
decimals
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
valueThe value
scalingThe 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
value
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
valueThe floating point value
multiplierThe value to multiply with before chopping of the decimal part
applySignWhether or not to apply the sign.
Returns
The integer representing the floating point value.

Definition at line 90 of file float.c.