[DGD]Extensions interface: floats
Michael J. Bacon
mj.bacon at gte.net
Tue Jun 19 01:47:45 CEST 2001
> 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);
FYI: This seemed to work great for floats > 0 but floats < 0 were coming
out wrong. I changed it as follows and it seems to work:
mantissa = ldexp(frexp(fabs(f), &exponent), 37);
Thanks;
Michael.
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list