 |
bcd_var |
Function (Macro) |
Converts reference to float object to reference to BCD object.
bcd_var converts the reference to a floating point object x (which must be an lvalue,
for example a floating point variable) to the reference to the same object, but interpreted
as a bcd structure. bcd_var is similar as float_to_bcd,
but returned object is an lvalue, so it may be used in assignments like
float a;
...
bcd_var(a).exponent = 0x4002;
The drawback of bcd_var (compared with float_to_bcd) is the fact
that its argument must be an lvalue, so it can not be a floating point constant or any
non-lvalue expression (for example, a result of a function).
Note: I used notation "&bcd_var" and "&x" in the prototype description, although passing
by reference and returning results by reference does not exist in ordinary C (only in C++).
However, this bcd_var is macro which is implemented on such way that it simulates
"passing and returning by reference".