float_to_bcd Function (Macro)

timath.h

bcd float_to_bcd (float x);

Converts float to BCD.

bcd_to_float converts BCD structure x into an ordinary floating point value. In fact, this function returns the same value as the argument, but with different interpretation. This function, in a way, performs typecasting from an ordinary float type to a bcd type. Beware that returned value is not an lvalue (ordinary C functions never return lvalues, by the way), so you can not do something like

float a;
...
float_to_bcd(a).exponent = 0x4002;
To perform such assignments, use bcd_var macro.