NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
encoding.h File Reference
#include <stdint.h>
Include dependency graph for encoding.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint32_t castFloatBytesToInt (float f)
 
uint32_t zigzagEncode (int32_t value)
 

Function Documentation

uint32_t castFloatBytesToInt ( float  f)

Cast the in-memory representation of the given float directly to an int.

This is useful for printing the hex representation of a float number (which is considerably cheaper than a full decimal float formatter, in both code size and output length).

uint32_t zigzagEncode ( int32_t  value)

ZigZag encoding maps all values of a signed integer into those of an unsigned integer in such a way that numbers of small absolute value correspond to small integers in the result.

(Compared to just casting a signed to an unsigned which creates huge resulting numbers for small negative integers).