Hello,
I need to convert a standard 32 bit floating point number to IEEE-11073 16-bit FLOAT with 12-bit mantissa and 4-bit exponent (source: https://infocenter.nordicsemi.com). Is there already an implementation in the sdk or an example somewhere? I tried it the following way, but the numbers in the nrf connect app where wrong.
#include "ble_bps.h" ieee_float16_t c_float32_to_ieee_11073_float16(float input){ ieee_float16_t ret; uint32_t input_raw = *((uint32_t*)&input); ret.mantissa = (input_raw >> 23) & 0xf; ret.exponent = (input_raw & 0xfff); return ret;}