[DGD]Extensions interface: floats
Felix A. Croes
felix at dworkin.nl
Wed Jun 13 21:20:54 CEST 2001
Thomas Annandale <thomas at boredatheist.com> wrote:
> In /dgd/doc/Extensions, DGD_FLOAT_GETVAL is documented as taking a
> DGD_VALUE_T for an argument and returning a DGD_FLOAT_T, though in
> actuality, it seems to take both the DGD_VALUE_T and the DGD_FLOAT_T as
> arguments.
This will be fixed (in the documentation) for the next patch.
> Also, how do I go about turning a DGD_FLOAT_T into the normal C float
> type?
After the next patch (there is a bug in this macro), use DGD_FLOAT_GET()
to retrieve the sign, exponent and mantissa, and then use the following
expression:
((sign) ? -1 : 1) * ldexp(mantissa, exponent - 36)
To go from C float to DGD_FLOAT_T, use:
sign = (f < 0);
mantissa = ldexp(frexp(f, &exponent), 37);
--exponent;
DGD_FLOAT_PUT(DGDflt, sign, exponent, mantissa);
Regards,
Dworkin
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list