avr-fw-modules/core/src/fp4816_from_float.c

16 lines
288 B
C
Executable File

#include <fixpoint/fp4816.h>
/*
fp4816_t fp4816_from_float(float value)
{
IEEEFLOAT ieee = { value };
int16_t exp = ieee.exponent - 127;
int32_t mantisse = ieee.mantisse | 0x00800000;
fp4816_t fp = (fp4816_t)(mantisse >> (15 - exp));
if (ieee.sign)
fp *= -1;
return fp;
};
*/