* mingwex/gdtoa/g_xfmt.c (g_xfmt): Fix representation of infinity. Use fpclassify.
* mingwex/gdtoa/strtopx (__strtopx): Avoid cast of long double* to void*. * mingwex/gdtoa/gdtoa.h (__g_fmt): Make declaration consistent with others.
This commit is contained in:
parent
7aa8dc8eb0
commit
dad3363707
@ -1,3 +1,12 @@
|
|||||||
|
2006-09-18 Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
|
||||||
|
* mingwex/gdtoa/g_xfmt.c (g_xfmt): Fix representation of infinity.
|
||||||
|
Use fpclassify.
|
||||||
|
* mingwex/gdtoa/strtopx (__strtopx): Avoid cast of long double* to
|
||||||
|
void*.
|
||||||
|
* mingwex/gdtoa/gdtoa.h (__g_fmt): Make declaration consistent with
|
||||||
|
others.
|
||||||
|
|
||||||
2006-09-16 Danny Smith <dannysmith@users.sourceforge.net>
|
2006-09-16 Danny Smith <dannysmith@users.sourceforge.net>
|
||||||
|
|
||||||
* mingwex/gdtoa/strtopx.c (strtopx): Fix long double representation
|
* mingwex/gdtoa/strtopx.c (strtopx): Fix long double representation
|
||||||
|
@ -64,6 +64,8 @@ __g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
|
|||||||
UShort *L;
|
UShort *L;
|
||||||
int decpt, ex, i, mode;
|
int decpt, ex, i, mode;
|
||||||
|
|
||||||
|
int fptype = __fpclassifyl (*(long double*) V);
|
||||||
|
|
||||||
if (ndig < 0)
|
if (ndig < 0)
|
||||||
ndig = 0;
|
ndig = 0;
|
||||||
if (bufsize < ndig + 10)
|
if (bufsize < ndig + 10)
|
||||||
@ -71,28 +73,36 @@ __g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
|
|||||||
|
|
||||||
L = (UShort *)V;
|
L = (UShort *)V;
|
||||||
sign = L[_0] & 0x8000;
|
sign = L[_0] & 0x8000;
|
||||||
|
ex = L[_0] & 0x7fff;
|
||||||
|
|
||||||
bits[1] = (L[_1] << 16) | L[_2];
|
bits[1] = (L[_1] << 16) | L[_2];
|
||||||
bits[0] = (L[_3] << 16) | L[_4];
|
bits[0] = (L[_3] << 16) | L[_4];
|
||||||
if ( (ex = L[_0] & 0x7fff) !=0) {
|
|
||||||
if (ex == 0x7fff) {
|
if (fptype & FP_NAN) /* NaN or Inf */
|
||||||
/* Infinity or NaN */
|
{
|
||||||
if (bits[0] | bits[1])
|
if (fptype & FP_NORMAL)
|
||||||
b = strcp(buf, "NaN");
|
{
|
||||||
else {
|
b = buf;
|
||||||
b = buf;
|
*b++ = sign ? '-': '+';
|
||||||
if (sign)
|
strncpy (b, "Infinity", ndig ? ndig : 8);
|
||||||
*b++ = '-';
|
return (buf + strlen (buf));
|
||||||
b = strcp(b, "Infinity");
|
}
|
||||||
}
|
strncpy (buf, "NaN", ndig ? ndig : 3);
|
||||||
return b;
|
return (buf + strlen (buf));
|
||||||
}
|
}
|
||||||
i = STRTOG_Normal;
|
|
||||||
}
|
else if (fptype & FP_NORMAL) /* Normal or subnormal */
|
||||||
else if (bits[0] | bits[1]) {
|
{
|
||||||
|
if (fptype & FP_ZERO)
|
||||||
|
{
|
||||||
i = STRTOG_Denormal;
|
i = STRTOG_Denormal;
|
||||||
ex = 1;
|
ex = 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
i = STRTOG_Normal;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
|
i = STRTOG_Zero;
|
||||||
b = buf;
|
b = buf;
|
||||||
#ifndef IGNORE_ZERO_SIGN
|
#ifndef IGNORE_ZERO_SIGN
|
||||||
if (sign)
|
if (sign)
|
||||||
@ -102,6 +112,7 @@ __g_xfmt(char *buf, void *V, int ndig, unsigned bufsize)
|
|||||||
*b = 0;
|
*b = 0;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
ex -= 0x3fff + 63;
|
ex -= 0x3fff + 63;
|
||||||
mode = 2;
|
mode = 2;
|
||||||
if (ndig <= 0) {
|
if (ndig <= 0) {
|
||||||
|
@ -116,7 +116,7 @@ extern float __strtof ANSI((CONST char *, char **));
|
|||||||
extern double __strtod ANSI((CONST char *, char **));
|
extern double __strtod ANSI((CONST char *, char **));
|
||||||
extern long double strtold ANSI((CONST char *, char **));
|
extern long double strtold ANSI((CONST char *, char **));
|
||||||
|
|
||||||
extern char* __g__fmt(char *, char *, char *e, int, ULong);
|
extern char* __g__fmt ANSI((char *, char *, char *e, int, ULong));
|
||||||
extern char* __g_dfmt ANSI((char*, double*, int, unsigned));
|
extern char* __g_dfmt ANSI((char*, double*, int, unsigned));
|
||||||
extern char* __g_ffmt ANSI((char*, float*, int, unsigned));
|
extern char* __g_ffmt ANSI((char*, float*, int, unsigned));
|
||||||
extern char* __g_xfmt ANSI((char*, void*, int, unsigned));
|
extern char* __g_xfmt ANSI((char*, void*, int, unsigned));
|
||||||
|
@ -53,9 +53,9 @@ THIS SOFTWARE.
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
#ifdef KR_headers
|
#ifdef KR_headers
|
||||||
__strtopx(s, sp, V) CONST char *s; char **sp; void *V;
|
__strtopx(s, sp, V) CONST char *s; char **sp; long double *V;
|
||||||
#else
|
#else
|
||||||
__strtopx(CONST char *s, char **sp, void *V)
|
__strtopx(CONST char *s, char **sp, long double *V)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
|
static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI };
|
||||||
@ -108,7 +108,7 @@ __cdecl
|
|||||||
__strtold (const char * __restrict__ src, char ** __restrict__ endptr)
|
__strtold (const char * __restrict__ src, char ** __restrict__ endptr)
|
||||||
{
|
{
|
||||||
long double ret;
|
long double ret;
|
||||||
__strtopx(src, endptr, (void*) &ret);
|
__strtopx(src, endptr, &ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user