2009-04-16 Ozkan Sezer <sezeroz@gmail.com>

* gdtoa/g_xfmt.c: Added maintream code for general purposes and kept
	our fpclassiy() code for mingw builds.


git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@795 4407c894-4637-0410-b4f5-ada5f102cad1
This commit is contained in:
Ozkan Sezer 2009-04-16 13:25:35 +00:00
parent b0445975ac
commit 17007aa7ee
2 changed files with 32 additions and 3 deletions

View File

@ -18,6 +18,9 @@
cases, such as dtoa calls in mode 3 with thousands of digits requested,
or strtod() calls with thousand of digits. from the netlib.org sources.
* gdtoa/g_xfmt.c: Added maintream code for general purposes and kept
our fpclassiy() code for mingw builds.
2009-04-15 Kai Tietz <kai.tietz@onevision.com>
* math/copysign.c: Avoid breaking of strict aliasing.

View File

@ -58,7 +58,9 @@ char *__g_xfmt (char *buf, void *V, int ndig, size_t bufsize)
ULong bits[2], sign;
UShort *L;
int decpt, ex, i, mode;
#if defined(__MIRGW32__) || defined(__MIRGW64__)
int fptype = __fpclassifyl (*(long double*) V);
#endif /* MinGW */
#ifdef Honor_FLT_ROUNDS
#include "gdtoa_fltrnds.h"
#else
@ -76,7 +78,9 @@ char *__g_xfmt (char *buf, void *V, int ndig, size_t bufsize)
bits[1] = (L[_1] << 16) | L[_2];
bits[0] = (L[_3] << 16) | L[_4];
if (fptype & FP_NAN) { /* NaN or Inf */
#if defined(__MIRGW32__) || defined(__MIRGW64__)
if (fptype & FP_NAN) {
/* NaN or Inf */
if (fptype & FP_NORMAL) {
b = buf;
*b++ = sign ? '-': '+';
@ -86,7 +90,8 @@ char *__g_xfmt (char *buf, void *V, int ndig, size_t bufsize)
strncpy (buf, "NaN", ndig ? ndig : 3);
return (buf + strlen (buf));
}
else if (fptype & FP_NORMAL) { /* Normal or subnormal */
else if (fptype & FP_NORMAL) {
/* Normal or subnormal */
if (fptype & FP_ZERO) {
i = STRTOG_Denormal;
ex = 1;
@ -94,8 +99,29 @@ char *__g_xfmt (char *buf, void *V, int ndig, size_t bufsize)
else
i = STRTOG_Normal;
}
#else
if (ex != 0) {
if (ex == 0x7fff) {
/* Infinity or NaN */
if (bits[0] | bits[1])
b = strcp(buf, "NaN");
else {
b = buf;
if (sign)
*b++ = '-';
b = strcp(b, "Infinity");
}
return b;
}
i = STRTOG_Normal;
}
else if (bits[0] | bits[1]) {
i = STRTOG_Denormal;
ex = 1;
}
#endif
else {
i = STRTOG_Zero;
/* i = STRTOG_Zero; */
b = buf;
#ifndef IGNORE_ZERO_SIGN
if (sign)