2 #include "gdtoa/gdtoa.h"
4 /* This code is patterned on g_ffmt from the gdtoa sources. */
5 C_String_t
Real32_gdtoa (Real32_t f
, C_Int_t mode
, C_Int_t ndig
,
6 C_Int_t rounding
, Ref(C_Int_t
) decpt
) {
7 FPI fpi
= { 24, 1-127-24+1, 254-127-24+1, (int)rounding
, 0, 6 };
12 memcpy(L
, &f
, sizeof(Real32_t
));
13 bits
[0] = L
[0] & 0x7fffff;
14 if ((ex
= (L
[0] >> 23) & 0xff) != 0)
20 result
= gdtoa__gdtoa (&fpi
, ex
, bits
, &i
, (int)mode
, (int)ndig
, (int*)decpt
, NULL
);
21 return (C_String_t
)result
;
24 /* This code is patterned on g_dfmt from the gdtoa sources. */
25 C_String_t
Real64_gdtoa (Real64_t d
, C_Int_t mode
, C_Int_t ndig
,
26 C_Int_t rounding
, Ref(C_Int_t
) decpt
) {
27 FPI fpi
= { 53, 1-1023-53+1, 2046-1023-53+1, (int)rounding
, 0, 14 };
40 memcpy(L
, &d
, sizeof(Real64_t
));
42 bits
[1] = L
[x0
] & 0xfffff;
43 if ((ex
= (L
[x0
] >> 20) & 0x7ff) != 0)
49 result
= gdtoa__gdtoa (&fpi
, ex
, bits
, &i
, mode
, ndig
, (int*)decpt
, NULL
);
50 return (C_String_t
)result
;