38#ifndef __OPENLCB_FLOAT16__
39#define __OPENLCB_FLOAT16__
49#define FLOAT16_POSITIVE_ZERO 0x0000
52#define FLOAT16_NEGATIVE_ZERO 0x8000
55#define FLOAT16_NAN 0x7E00
58#define FLOAT16_SIGN_MASK 0x8000
61#define FLOAT16_EXPONENT_MASK 0x7C00
64#define FLOAT16_MANTISSA_MASK 0x03FF
bool OpenLcbFloat16_get_direction(uint16_t half)
Returns true if the direction bit is set (reverse).
Definition openlcb_float16.c:281
uint16_t OpenLcbFloat16_negate(uint16_t half)
Flips the sign/direction bit of a float16 value and returns the result.
Definition openlcb_float16.c:217
uint16_t OpenLcbFloat16_from_float(float value)
Converts a 32-bit float to a float16 bit pattern.
Definition openlcb_float16.c:83
float OpenLcbFloat16_to_float(uint16_t half)
Converts a float16 bit pattern to a 32-bit float.
Definition openlcb_float16.c:163
float OpenLcbFloat16_get_speed(uint16_t half)
Returns the speed magnitude from a float16 bit pattern (ignores direction).
Definition openlcb_float16.c:270
bool OpenLcbFloat16_is_nan(uint16_t half)
Returns true if the float16 bit pattern represents NaN (speed not available).
Definition openlcb_float16.c:225
bool OpenLcbFloat16_is_zero(uint16_t half)
Returns true if the float16 bit pattern represents positive or negative zero.
Definition openlcb_float16.c:236
uint16_t OpenLcbFloat16_speed_with_direction(float speed, bool reverse)
Encodes a speed magnitude and direction into a float16 bit pattern.
Definition openlcb_float16.c:244