summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Qtest.c23
-rw-r--r--test/README6
-rw-r--r--test/ddtest.c2
-rw-r--r--test/dt.c112
-rw-r--r--test/dtest.c2
-rw-r--r--test/ftest.c2
-rw-r--r--test/getround.c2
-rw-r--r--test/makefile31
-rw-r--r--test/pfLqtestnos13
-rw-r--r--test/pftest.c158
-rw-r--r--test/pftestLq.out13
-rw-r--r--test/pftestQ.out15
-rw-r--r--test/pftestnos15
-rw-r--r--test/pftestx.out15
-rw-r--r--test/strtodt.c8
-rw-r--r--test/testnos324
-rw-r--r--test/xLtest.c8
-rw-r--r--test/xQtest.c22
-rw-r--r--test/xsum0.out54
-rw-r--r--test/xtest.c4
20 files changed, 423 insertions, 106 deletions
diff --git a/test/Qtest.c b/test/Qtest.c
index f694afb603e1..a94466a09f53 100644
--- a/test/Qtest.c
+++ b/test/Qtest.c
@@ -81,9 +81,14 @@ THIS SOFTWARE.
main(Void)
{
char *s, *s1, *se, *se1;
- int i, dItry, ndig = 0, r = 1;
- union { long double d; ULong bits[4]; } u, v[2];
+ int Ltest, i, dItry, ndig = 0, r = 1;
+ union { long double d; ULong bits[4]; } u, v[2], w;
+ w.bits[0] = w.bits[3] = 0;
+ w.d = 1.;
+ u.d = 3.;
+ w.d = w.d / u.d;
+ Ltest = sizeof(long double) == 16 && w.bits[0] && w.bits[3];
while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) {
while(*s <= ' ')
if (!*s++)
@@ -95,7 +100,7 @@ main(Void)
continue;
case 'n':
i = s[1];
- if (i <= ' ' || i >= '0' && i <= '9') {
+ if (i <= ' ' || (i >= '0' && i <= '9')) {
ndig = atoi(s+1);
continue;
}
@@ -113,8 +118,8 @@ main(Void)
}
}
printf("\nInput: %s", ibuf);
- printf(" --> f = #%lx %lx %lx %lx\n", u.bits[_0],
- u.bits[_1], u.bits[_2], u.bits[_3]);
+ printf(" --> f = #%lx %lx %lx %lx\n", U u.bits[_0],
+ U u.bits[_1], U u.bits[_2], U u.bits[_3]);
goto fmt_test;
}
dItry = 1;
@@ -128,7 +133,7 @@ main(Void)
printf("with bits = #%lx %lx %lx %lx\n",
U u.bits[_0], U u.bits[_1], U u.bits[_2], U u.bits[_3]);
fmt_test:
- if (sizeof(long double) == 16)
+ if (Ltest)
printf("printf(\"%%.35Lg\") gives %.35Lg\n", u.d);
se = g_Qfmt(obuf, u.bits, ndig, sizeof(obuf));
printf("g_Qfmt(%d) gives %d bytes: \"%s\"\n\n", ndig,
@@ -145,7 +150,7 @@ main(Void)
printf("fI[0] == fI[1] = #%lx %lx %lx %lx\n",
U v[0].bits[_0], U v[0].bits[_1],
U v[0].bits[_2], U v[0].bits[_3]);
- if (sizeof(long double) == 16)
+ if (Ltest)
printf("= %.35Lg\n", v[0].d);
}
}
@@ -153,12 +158,12 @@ main(Void)
printf("fI[0] = #%lx %lx %lx %lx\n",
U v[0].bits[_0], U v[0].bits[_1],
U v[0].bits[_2], U v[0].bits[_3]);
- if (sizeof(long double) == 16)
+ if (Ltest)
printf("= %.35Lg\n", v[0].d);
printf("fI[1] = #%lx %lx %lx %lx\n",
U v[1].bits[_0], U v[1].bits[_1],
U v[1].bits[_2], U v[1].bits[_3]);
- if (sizeof(long double) == 16)
+ if (Ltest)
printf("= %.35Lg\n", v[1].d);
if (!memcmp(v[0].bits, u.bits, 16))
printf("fI[0] == strtod\n");
diff --git a/test/README b/test/README
index 107620539389..042ecfea0aac 100644
--- a/test/README
+++ b/test/README
@@ -69,6 +69,12 @@ You can also or alternatively compile getround.c with
-DUSE_MY_LOCALE (when ../gdtoa.a is compiled with -DUSE_LOCALE)
to test multi-byte decimal points.
+If in the parent directory, you have sucessfully invoked "make Printf"
+to add a "printf" (called Printf and accessed via ../stdio1.h), then
+here you can use "make pf_test" and (if you have both a 64-bit long
+double and a 113-bit "quad" double type) "make pf_testLq" for a brief
+test of %g and %a variants in Printf.
+
These are simple test programs, not meant for exhaustive testing,
but for manually testing "interesting" cases. Paxson's testbase
is good for more exhaustive testing, in part with random inputs.
diff --git a/test/ddtest.c b/test/ddtest.c
index 6fc32511be05..2cf31524a905 100644
--- a/test/ddtest.c
+++ b/test/ddtest.c
@@ -94,7 +94,7 @@ main(Void)
continue;
case 'n':
i = s[1];
- if (i <= ' ' || i >= '0' && i <= '9') {
+ if (i <= ' ' || (i >= '0' && i <= '9')) {
ndig = atoi(s+1);
continue;
}
diff --git a/test/dt.c b/test/dt.c
index ed0daeb37e43..355476ff2797 100644
--- a/test/dt.c
+++ b/test/dt.c
@@ -44,6 +44,7 @@ THIS SOFTWARE.
#include <stdio.h>
#include "gdtoa.h"
+int STRTOD_DIGLIM = 24;
#ifdef KR_headers
#define Void /*void*/
#else
@@ -59,13 +60,18 @@ extern "C" double atof(const char*);
extern double atof ANSI((char*));
#endif
#endif
+
+typedef union { double d; ULong L[2]; } U;
+
#ifdef IEEE_8087
-#define word0(x) ((ULong *)&x)[1]
-#define word1(x) ((ULong *)&x)[0]
+#define word0(x) (x)->L[1]
+#define word1(x) (x)->L[0]
#else
-#define word0(x) ((ULong *)&x)[0]
-#define word1(x) ((ULong *)&x)[1]
+#define word0(x) (x)->L[0]
+#define word1(x) (x)->L[1]
#endif
+#define dval(x) (x)->d
+
#include "errno.h"
#ifdef __cplusplus
@@ -93,14 +99,14 @@ g_fmt(char *b, double x)
if (sign)
*b++ = '-';
if (decpt == 9999) /* Infinity or Nan */ {
- while(*b++ = *s++);
+ while((*b++ = *s++));
return;
}
if (decpt <= -4 || decpt > se - s + 5) {
*b++ = *s++;
if (*s) {
*b++ = '.';
- while(*b = *s++)
+ while((*b = *s++))
b++;
}
*b++ = 'e';
@@ -126,10 +132,10 @@ g_fmt(char *b, double x)
*b++ = '.';
for(; decpt < 0; decpt++)
*b++ = '0';
- while(*b++ = *s++);
+ while((*b++ = *s++));
}
else {
- while(*b = *s++) {
+ while((*b = *s++)) {
b++;
if (--decpt == 0 && *s)
*b++ = '.';
@@ -148,40 +154,41 @@ baderrno(Void)
fflush(stderr);
}
-#define U (unsigned long)
+#define UL (unsigned long)
static void
#ifdef KR_headers
-check(d) double d;
+check(d) U *d;
#else
-check(double d)
+check(U *d)
#endif
{
char buf[64];
int decpt, sign;
char *s, *se;
- double d1;
+ U d1;
- s = dtoa(d, 0, 0, &decpt, &sign, &se);
+ s = dtoa(dval(d), 0, 0, &decpt, &sign, &se);
sprintf(buf, "%s%s%se%d", sign ? "-" : "",
decpt == 9999 ? "" : ".", s, decpt);
errno = 0;
- d1 = strtod(buf, (char **)0);
+ dval(&d1) = strtod(buf, (char **)0);
if (errno)
baderrno();
- if (d != d1) {
+ if (dval(d) != dval(&d1)) {
printf("sent d = %.17g = 0x%lx %lx, buf = %s\n",
- d, U word0(d), U word1(d), buf);
+ dval(d), UL word0(d), UL word1(d), buf);
printf("got d1 = %.17g = 0x%lx %lx\n",
- d1, U word0(d1), U word1(d1));
+ dval(&d1), UL word0(&d1), UL word1(&d1));
}
}
int
-main(Void){
+main(Void)
+{
+ U d, d1;
char buf[2048], buf1[32];
char *fmt, *s, *s1, *se;
- double d, d1;
int decpt, sign;
int mode = 0, ndigits = 17;
ULong x, y;
@@ -196,8 +203,8 @@ main(Void){
}
printf("Input: %s", buf);
if (*buf == '#') {
- x = word0(d);
- y = word1(d);
+ x = word0(&d);
+ y = word1(&d);
/* sscanf(buf+1, "%lx %lx:%d %d", &x, &y, &mode, &ndigits); */
x = (ULong)strtoul(s1 = buf+1, &se, 16);
if (se > s1) {
@@ -205,72 +212,79 @@ main(Void){
if (se > s1)
sscanf(se, ":%d %d", &mode, &ndigits);
}
- word0(d) = x;
- word1(d) = y;
+ word0(&d) = x;
+ word1(&d) = y;
fmt = "Output: d =\n%.17g = 0x%lx %lx\n";
}
+ else if (*buf == '*') {
+ x = strtoul(buf,&s,10);
+ if (!*s && x > 18)
+ STRTOD_DIGLIM = (int)x;
+ printf("STRTOD_DIGLIM = %lu\n", UL x);
+ continue;
+ }
else {
errno = 0;
- d = strtod(buf,&se);
+ dval(&d) = strtod(buf,&se);
if (*se == ':')
sscanf(se+1,"%d %d", &mode, &ndigits);
- d1 = atof(buf);
+ dval(&d1) = atof(buf);
fmt = "Output: d =\n%.17g = 0x%lx %lx, se = %s";
if (errno)
baderrno();
}
- printf(fmt, d, U word0(d), U word1(d), se);
- g_fmt(buf1, d);
+ printf(fmt, dval(&d), UL word0(&d), UL word1(&d), se);
+ g_fmt(buf1, dval(&d));
printf("\tg_fmt gives \"%s\"\n", buf1);
- if (*buf != '#' && d != d1)
+ if (*buf != '#' && dval(&d) != dval(&d1))
printf("atof gives\n\
d1 = %.17g = 0x%lx %lx\nversus\n\
- d = %.17g = 0x%lx %lx\n", d1, U word0(d1), U word1(d1),
- d, U word0(d), U word1(d));
- check(d);
- s = dtoa(d, mode, ndigits, &decpt, &sign, &se);
+ d = %.17g = 0x%lx %lx\n", dval(&d1), UL word0(&d1), UL word1(&d1),
+ dval(&d), UL word0(&d), UL word1(&d));
+ check(&d);
+ s = dtoa(dval(&d), mode, ndigits, &decpt, &sign, &se);
printf("\tdtoa(mode = %d, ndigits = %d):\n", mode, ndigits);
printf("\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n",
- sign, decpt, se-s, s);
- x = word1(d);
+ sign, decpt, (int)(se-s), s);
+ x = word1(&d);
if (x != 0xffffffff
- && (word0(d) & 0x7ff00000) != 0x7ff00000) {
+ && (word0(&d) & 0x7ff00000) != 0x7ff00000) {
#ifdef VAX
z = x << 16 | x >> 16;
z++;
z = z << 16 | z >> 16;
- word1(d) = z;
+ word1(&d) = z;
#else
- word1(d) = x + 1;
+ word1(&d) = x + 1;
#endif
printf("\tnextafter(d,+Inf) = %.17g = 0x%lx %lx:\n",
- d, U word0(d), U word1(d));
- g_fmt(buf1, d);
+ dval(&d), UL word0(&d), UL word1(&d));
+ g_fmt(buf1, dval(&d));
printf("\tg_fmt gives \"%s\"\n", buf1);
- s = dtoa(d, mode, ndigits, &decpt, &sign, &se);
+ s = dtoa(dval(&d), mode, ndigits, &decpt, &sign, &se);
printf(
"\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n",
- sign, decpt, se-s, s);
- check(d);
+ sign, decpt, (int)(se-s), s);
+ check(&d);
}
if (x) {
#ifdef VAX
z = x << 16 | x >> 16;
z--;
z = z << 16 | z >> 16;
- word1(d) = z;
+ word1(&d) = z;
#else
- word1(d) = x - 1;
+ word1(&d) = x - 1;
#endif
printf("\tnextafter(d,-Inf) = %.17g = 0x%lx %lx:\n",
- d, U word0(d), U word1(d));
- g_fmt(buf1, d);
+ dval(&d), UL word0(&d), UL word1(&d));
+ g_fmt(buf1, dval(&d));
printf("\tg_fmt gives \"%s\"\n", buf1);
- s = dtoa(d, mode, ndigits, &decpt, &sign, &se);
+ s = dtoa(dval(&d), mode, ndigits, &decpt, &sign, &se);
printf(
"\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n",
- sign, decpt, se-s, s);
- check(d);
+ sign, decpt, (int)(se-s), s);
+ check(&d);
}
}
return 0;
diff --git a/test/dtest.c b/test/dtest.c
index adcbfd11a228..0140f2ed3260 100644
--- a/test/dtest.c
+++ b/test/dtest.c
@@ -78,7 +78,7 @@ main(Void)
continue;
case 'n':
i = s[1];
- if (i <= ' ' || i >= '0' && i <= '9') {
+ if (i <= ' ' || (i >= '0' && i <= '9')) {
ndig = atoi(s+1);
continue;
}
diff --git a/test/ftest.c b/test/ftest.c
index 9f6e144ae7b6..2006fdcdd428 100644
--- a/test/ftest.c
+++ b/test/ftest.c
@@ -77,7 +77,7 @@ main(Void)
continue;
case 'n':
i = s[1];
- if (i <= ' ' || i >= '0' && i <= '9') {
+ if (i <= ' ' || (i >= '0' && i <= '9')) {
ndig = atoi(s+1);
continue;
}
diff --git a/test/getround.c b/test/getround.c
index e67e14fd4bd0..05eb199e7737 100644
--- a/test/getround.c
+++ b/test/getround.c
@@ -55,7 +55,7 @@ getround(int r, char *s)
r, dir[r]);
return r;
}
- }
+ }
i = atoi(s);
if (i >= 0 && i < 4) {
printf("Rounding mode for strtor... ");
diff --git a/test/makefile b/test/makefile
index 243b5a62a76f..a409fa166a0d 100644
--- a/test/makefile
+++ b/test/makefile
@@ -91,6 +91,10 @@ strtodt = strtodt.o $A
strtodt: $(strtodt)
$(CC) -o strtodt $(strtodt) $L
+pftest = pftest.o $A
+pftest: ../Printf $(pftest)
+ $(CC) -o pftest $(pftest) $L
+
## On Intel (and Intel-like) systems using extended-precision registers
## for double-precision (C type double) computations that sometimes suffer
## double rounding errors, the test below involving strtodt generally shows
@@ -138,16 +142,31 @@ tests: Q.out x.out xL.out dt dItest ddtest dtest ftest Qtest xLtest xtest ddtest
(cd bad; for i in *; do cmp -s $$i ../obad/$$i && rm $$i;done; cd ..; rmdir bad)
touch tests
-xs0 = README Qtest.c dItest.c ddtest.c dtest.c dt.c ftest.c getround.c \
- strtoIdSI.c strtoIddSI.c strtodISI.c strtodt.c strtopddSI.c \
- strtorddSI.c xLtest.c xQtest.c xtest.c rtestnos testnos testnos1 \
- testnos3 dI.out dIsi.out ddsi.out dd.out dtst.out d.out f.out \
- x.ou0 xL.ou0 x.ou1 xL.ou1 Q.ou0 Q.ou1 makefile
+# To test Printf in ../gdtoa.a, "make pf_test" and perhaps "make pf_testLq"
+# (if both long double and quad are desired and available).
+
+pf_test: pftest
+ ./pftest <pftestnos >zap
+ cmp pftest.out zap && rm zap
+
+pf_testLq: pftest
+ ./pftest <pfLqtestnos >zap
+ cmp pftestLq.out zap && rm zap
+
+xs0 = README Q.ou0 Q.ou1 Qtest.c d.out dI.out dIsi.out dItest.c dd.out\
+ ddsi.out ddtest.c dt.c dtest.c dtst.out f.out ftest.c\
+ getround.c makefile pfLqtestnos pftest.c pftestQ.out\
+ pftestx.out pftestLq.out pftestnos rtestnos strtoIdSI.c\
+ strtoIddSI.c strtodISI.c strtodt.c strtopddSI.c strtorddSI.c\
+ testnos testnos1 testnos3 x.ou0 x.ou1 xL.ou0 xL.ou1 xLtest.c\
+ xQtest.c xtest.c
+# invoke "make -r xsum.out"
xsum.out: xsum0.out $(xs0)
xsum $(xs0) >xsum1.out
cmp xsum0.out xsum1.out && mv xsum1.out xsum.out || diff xsum[01].out
clean:
- rm -f *.[ao] dt *test *testsi strtodt strtodtnrp xsum.out xsum1.out tests zap x.out xL.out Q.out
+ rm -f *.[ao] dt *test *testsi pftest.out strtodt strtodtnrp xsum.out\
+ xsum1.out tests zap x.out xL.out Q.out
rm -rf bad
diff --git a/test/pfLqtestnos b/test/pfLqtestnos
new file mode 100644
index 000000000000..0680923378b8
--- /dev/null
+++ b/test/pfLqtestnos
@@ -0,0 +1,13 @@
+%.8a 1.23
+%.7a
+%.2a
+%.La 1.23
+%.20Lqa 1.23
+%La 3e27
+%La 1.7e27
+%Lqa 3e48
+%Lqa 1e49
+1.5
+2.5
+4.5
+8.5
diff --git a/test/pftest.c b/test/pftest.c
new file mode 100644
index 000000000000..99d78ee451c1
--- /dev/null
+++ b/test/pftest.c
@@ -0,0 +1,158 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 2009 by David M. Gay
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+source-code copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation.
+
+THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+****************************************************************/
+#include "stdio1.h"
+#include "gdtoa.h"
+#include <string.h>
+
+#undef allow_Quad
+#undef want_Quad
+#undef want_Ux
+#define want_LD
+typedef union Ud {double x; unsigned int u[2]; } Ud;
+#ifdef __x86_64 /*{{*/
+#define want_Ux
+#ifndef NO_GDTOA_i386_Quad /*{*/
+typedef union UQ {__float128 x; unsigned int u[4]; } UQ;
+#define allow_Quad(x) x
+#define want_Quad
+#endif /*}*/
+#else /*}{*/
+#ifdef __i386 /*{{*/
+#define want_Ux
+#else /*}{*/
+#ifdef __sparc /*{{*/
+typedef union UQ {long double x; unsigned int u[4]; } Ux;
+#else /*}{*/
+#ifdef __INTEL_COMPILER /*{*/
+#undef want_Quad
+#undef want_Ux
+#undef want_LD
+#endif /*}*/
+#endif /*}}*/
+#endif /*}}*/
+#endif /*}}*/
+
+#ifndef allow_Quad
+#define allow_Quad(x) /*nothing*/
+#endif
+
+#ifdef want_Ux /*{{*/
+typedef union Ux {long double x; unsigned short u[5]; } Ux;
+#else /*}{*/
+#ifdef __sparc
+#define want_Ux
+#endif
+#endif /*}}*/
+
+ int
+main(void)
+{
+ Ud d;
+ allow_Quad(UQ q;)
+ char *b, buf[256], fmt[32], *s;
+#ifdef want_Ux
+ Ux x;
+ x.x = 0.;
+#endif
+ int k;
+
+ k = 0;
+ strcpy(fmt, "%.g");
+ d.x = 0.;
+ allow_Quad(q.x = 0.;)
+ while(fgets(buf, sizeof(buf), stdin)) {
+ for(b = buf; *b && *b != '\n'; ++b);
+ *b = 0;
+ if (b == buf)
+ continue;
+ b = buf;
+ if (*b == '%') {
+ for(k = 0; *b > ' '; ++b)
+#ifdef want_LD /*{{*/
+ switch(*b) {
+ case 'L':
+ k = 1;
+#ifdef want_Quad
+ break;
+ case 'q':
+ if (k >= 1)
+ k = 2;
+#endif
+ }
+#else /*}{*/
+ ;
+#endif /*}}*/
+ if (*b)
+ *b++ = 0;
+ if (b - buf < sizeof(fmt)) {
+ strcpy(fmt, buf);
+ }
+ }
+ if (*b) {
+ switch(k) {
+ case 0:
+ d.x = strtod(b,&s);
+ break;
+ case 1:
+#ifdef want_Ux
+#ifdef __sparc
+ strtopQ(b,&s,&x.x);
+#else
+ strtopx(b,&s,&x.x);
+#endif
+#else
+ strtopQ(b,&s,&q.x);
+#endif
+ break;
+ allow_Quad(case 2: strtopQ(b,&s,&q.x);)
+ }
+ if (*s)
+ printf("Ignoring \"%s\"\n", s);
+ }
+ switch(k) {
+ case 0:
+ printf("d.x = %.g = #%x %x; %s ==> ", d.x, d.u[1], d.u[0], fmt);
+ printf(fmt, d.x);
+ break;
+ case 1:
+#ifdef __sparc
+ printf("x.x = %.Lg = #%x %x %x %x; %s ==> ", x.x,
+ x.u[0], x.u[1], x.u[2], x.u[3], fmt);
+#else
+ printf("x.x = %.Lg = #%x %x %x %x %x; %s ==> ", x.x,
+ x.u[4], x.u[3], x.u[2], x.u[1], x.u[0], fmt);
+#endif
+ printf(fmt, x.x);
+#ifdef want_Quad
+ break;
+ case 2:
+ printf("q.x = %.Lqg = #%x %x %x %x; %s ==> ", q.x,
+ q.u[3], q.u[2], q.u[1], q.u[0], fmt);
+ printf(fmt, q.x);
+#endif
+ }
+ putchar('\n');
+ }
+ return 0;
+ }
diff --git a/test/pftestLq.out b/test/pftestLq.out
new file mode 100644
index 000000000000..0bcec7461a1d
--- /dev/null
+++ b/test/pftestLq.out
@@ -0,0 +1,13 @@
+d.x = 1.23 = #3ff3ae14 7ae147ae; %.8a ==> 0x1.3ae147aep+0
+d.x = 1.23 = #3ff3ae14 7ae147ae; %.7a ==> 0x1.3ae147bp+0
+d.x = 1.23 = #3ff3ae14 7ae147ae; %.2a ==> 0x1.3bp+0
+x.x = 1.23 = #3fff 9d70 a3d7 a3d 70a4; %.La ==> 0xap-3
+q.x = 1.23 = #3fff3ae1 47ae147a e147ae14 7ae147ae; %.20Lqa ==> 0x1.3ae147ae147ae147ae14p+0
+x.x = 3e+27 = #405a 9b18 ab5d f718 b6c; %La ==> 0x9.b18ab5df7180b6cp+88
+x.x = 1.7e+27 = #4059 afc6 a015 291b 4024; %La ==> 0xa.fc6a015291b4024p+87
+q.x = 3e+48 = #40a006be 53879565 60c1e1a9 9c13ee2; %Lqa ==> 0x1.06be5387956560c1e1a909c13ee2p+161
+q.x = 1e+49 = #40a1b5e7 e08ca3a8 f6987819 baecbe22; %Lqa ==> 0x1.b5e7e08ca3a8f6987819baecbe22p+162
+q.x = 1.5 = #3fff8000 0 0 0; %Lqa ==> 0x1.8p+0
+q.x = 2.5 = #40004000 0 0 0; %Lqa ==> 0x1.4p+1
+q.x = 4.5 = #40012000 0 0 0; %Lqa ==> 0x1.2p+2
+q.x = 8.5 = #40021000 0 0 0; %Lqa ==> 0x1.1p+3
diff --git a/test/pftestQ.out b/test/pftestQ.out
new file mode 100644
index 000000000000..8c42afe69487
--- /dev/null
+++ b/test/pftestQ.out
@@ -0,0 +1,15 @@
+d.x = 1.23 = #7ae147ae 3ff3ae14; %.8a ==> 0x1.3ae147aep+0
+d.x = 1.23 = #7ae147ae 3ff3ae14; %.7a ==> 0x1.3ae147bp+0
+d.x = 1.23 = #7ae147ae 3ff3ae14; %.2a ==> 0x1.3bp+0
+x.x = 1.23 = #3fff3ae1 47ae147a e147ae14 7ae147ae; %.La ==> 0x1p+0
+x.x = 1.23 = #3fff3ae1 47ae147a e147ae14 7ae147ae; %.20La ==> 0x1.3ae147ae147ae147ae14p+0
+x.x = 3e+27 = #405a3631 56bbee30 16d70000 0; %La ==> 0x1.363156bbee3016d7p+91
+x.x = 1.7e+27 = #40595f8d 402a5236 80490000 0; %La ==> 0x1.5f8d402a52368049p+90
+d.x = 1.5 = #0 3ff80000; %a ==> 0x1.8p+0
+d.x = 2.5 = #0 40040000; %a ==> 0x1.4p+1
+d.x = 4.5 = #0 40120000; %a ==> 0x1.2p+2
+d.x = 8.5 = #0 40210000; %a ==> 0x1.1p+3
+x.x = 1.5 = #3fff8000 0 0 0; %La ==> 0x1.8p+0
+x.x = 2.5 = #40004000 0 0 0; %La ==> 0x1.4p+1
+x.x = 4.5 = #40012000 0 0 0; %La ==> 0x1.2p+2
+x.x = 8.5 = #40021000 0 0 0; %La ==> 0x1.1p+3
diff --git a/test/pftestnos b/test/pftestnos
new file mode 100644
index 000000000000..7b3010a8b4f2
--- /dev/null
+++ b/test/pftestnos
@@ -0,0 +1,15 @@
+%.8a 1.23
+%.7a
+%.2a
+%.La 1.23
+%.20La 1.23
+%La 3e27
+%La 1.7e27
+%a 1.5
+2.5
+4.5
+8.5
+%La 1.5
+2.5
+4.5
+8.5
diff --git a/test/pftestx.out b/test/pftestx.out
new file mode 100644
index 000000000000..15a08d3629c8
--- /dev/null
+++ b/test/pftestx.out
@@ -0,0 +1,15 @@
+d.x = 1.23 = #3ff3ae14 7ae147ae; %.8a ==> 0x1.3ae147aep+0
+d.x = 1.23 = #3ff3ae14 7ae147ae; %.7a ==> 0x1.3ae147bp+0
+d.x = 1.23 = #3ff3ae14 7ae147ae; %.2a ==> 0x1.3bp+0
+x.x = 1.23 = #3fff 9d70 a3d7 a3d 70a4; %.La ==> 0xap-3
+x.x = 1.23 = #3fff 9d70 a3d7 a3d 70a4; %.20La ==> 0x9.d70a3d70a3d70a4p-3
+x.x = 3e+27 = #405a 9b18 ab5d f718 b6c; %La ==> 0x9.b18ab5df7180b6cp+88
+x.x = 1.7e+27 = #4059 afc6 a015 291b 4024; %La ==> 0xa.fc6a015291b4024p+87
+d.x = 1.5 = #3ff80000 0; %a ==> 0x1.8p+0
+d.x = 2.5 = #40040000 0; %a ==> 0x1.4p+1
+d.x = 4.5 = #40120000 0; %a ==> 0x1.2p+2
+d.x = 8.5 = #40210000 0; %a ==> 0x1.1p+3
+x.x = 1.5 = #3fff c000 0 0 0; %La ==> 0xcp-3
+x.x = 2.5 = #4000 a000 0 0 0; %La ==> 0xap-2
+x.x = 4.5 = #4001 9000 0 0 0; %La ==> 0x9p-1
+x.x = 8.5 = #4002 8800 0 0 0; %La ==> 0x8.8p+0
diff --git a/test/strtodt.c b/test/strtodt.c
index 94c70213c211..2983615c0408 100644
--- a/test/strtodt.c
+++ b/test/strtodt.c
@@ -49,6 +49,8 @@ THIS SOFTWARE.
ULong L[2];
} U;
+#define UL (unsigned long)
+
static int
process(char *fname, FILE *f)
{
@@ -81,7 +83,7 @@ process(char *fname, FILE *f)
if (b.L[W0] != a.L[0] || b.L[W1] != a.L[1]) {
n++;
printf("Line %d of %s: got %lx %lx; expected %lx %lx\n",
- line, fname, b.L[W0], b.L[W1], a.L[0], a.L[1]);
+ line, fname, UL b.L[W0], UL b.L[W1], UL a.L[0], UL a.L[1]);
}
}
return n;
@@ -120,8 +122,8 @@ main(int argc, char **argv)
if (argc <= 1)
n = process("<stdin>", stdin);
else
- while(s = *++argv)
- if (f = fopen(s,"r")) {
+ while((s = *++argv))
+ if ((f = fopen(s,"r"))) {
n += process(s, f);
fclose(f);
}
diff --git a/test/testnos3 b/test/testnos3
index be489027edd7..2a7cf79444ee 100644
--- a/test/testnos3
+++ b/test/testnos3
@@ -326,3 +326,27 @@
# first is 2^-1075 (half the smallest denormal)
2.4703282292062327208828439643411068618252990130716238221279284125033775363510437593264991818081799618989828234772285886546332835517796989819938739800539093906315035659515570226392290858392449105184435931802849936536152500319370457678249219365623669863658480757001585769269903706311928279558551332927834338409351978015531246597263579574622766465272827220056374006485499977096599470454020828166226237857393450736339007967761930577506740176324673600968951340535537458516661134223766678604162159680461914467291840300530057530849048765391711386591646239524912623653881879636239373280423891018672348497668235089863388587925628302755995657524455507255189313690836254779186948667994968324049705821028513185451396213837722826145437693412532098591327667236328125e-324 0 0
2.47032822920623272e-324 0 0
+
+# examples reported by Mark Dickinson of bugs in the bigcomp() logic introduced
+# 20090316 in dtoa.c to speed handling of absurdly long input:
+12579816049008305546974391768996369464963024663104e-357 90bbd 7412d19f
+17489628565202117263145367596028389348922981857013e-357 c938e 9000492f
+18487398785991994634182916638542680759613590482273e-357 d4b3a ee198863
+32002864200581033134358724675198044527469366773928e-358 24d1e ed8448e3
+99999999999999994487665465554760717039532578546e-47 3ff00000 0
+1.0000000000000000100000000000000000000001e44 4911efc6 59cf7d4c
+1000000000000000000000000000000000000000e-16 44b52d02 c7e14af6
+10000000000000000000000000000000000000000e-17 44b52d02 c7e14af6
+10.900000000000000012345678912345678912345 4025cccc cccccccd
+104308485241983990666713401708072175773165034278685682646111762292409330928739751702404658197872319129036519947435319418387839758990478549477777586673075945844895981012024387992135617064532141489278815239849108105951619997829153633535314849999674266169258928940692239684771590065027025835804863585454872499320500023126142553932654370362024104462255244034053203998964360882487378334860197725139151265590832887433736189468858614521708567646743455601905935595381852723723645799866672558576993978025033590728687206296379801363024094048327273913079612469982585674824156000783167963081616214710691759864332339239688734656548790656486646106983450809073750535624894296242072010195710276073042036425579852459556183541199012652571123898996574563824424330960027873516082763671875e-1075 78026 65fd9600
+99037485700245683102805043437346965248029601286431e-373 0 2
+99617639833743863161109961162881027406769510558457e-373 0 2
+98852915025769345295749278351563179840130565591462e-372 0 14
+99059944827693569659153042769690930905148015876788e-373 0 2
+98914979205069368270421829889078356254059760327101e-372 0 14
+0.999999999999999999999999999999999999999999999e23 44b52d02 c7e14af6
+991633793189150720000000000000000000000000000000000000000e-33 44ea3f92 6bad90c6
+37652435753827922121470370984740152789920e234 78f1667a c9e75d61
+999999999999999996790597280027956716285163e-42 3ff00000 0
+9483973038658180570348795755328802873667739881500874740826641664593613312413122937394311083577538394191754403820631172036846773125424639263833553383990195662207006139342261292777056851379062046720e0 68a03d69 82f2f936
+20209005503919489280000000000000000000000000000000000000000e-40 43bc0bae 57e880e6
diff --git a/test/xLtest.c b/test/xLtest.c
index aba0cf538041..403ad83b62bc 100644
--- a/test/xLtest.c
+++ b/test/xLtest.c
@@ -83,7 +83,7 @@ main(Void)
int dItry, i, ndig = 0, r = 1;
union { long double d; ULong bits[3]; } u, v[2];
- while(s = fgets(ibuf, sizeof(ibuf), stdin)) {
+ while((s = fgets(ibuf, sizeof(ibuf), stdin))) {
while(*s <= ' ')
if (!*s++)
continue;
@@ -94,7 +94,7 @@ main(Void)
continue;
case 'n':
i = s[1];
- if (i <= ' ' || i >= '0' && i <= '9') {
+ if (i <= ' ' || (i >= '0' && i <= '9')) {
ndig = atoi(s+1);
continue;
}
@@ -109,8 +109,8 @@ main(Void)
u.bits[_2] = (ULong)strtoul(s1=se, &se, 16);
}
printf("\nInput: %s", ibuf);
- printf(" --> f = #%lx %lx %lx\n", u.bits[_0],
- u.bits[_1], u.bits[_2]);
+ printf(" --> f = #%lx %lx %lx\n", U u.bits[_0],
+ U u.bits[_1], U u.bits[_2]);
goto fmt_test;
}
dItry = 1;
diff --git a/test/xQtest.c b/test/xQtest.c
index 8dfe3652c42f..93bc4142ff2f 100644
--- a/test/xQtest.c
+++ b/test/xQtest.c
@@ -31,16 +31,28 @@ THIS SOFTWARE.
int
main(void)
{
+ union { long double d; unsigned int bits[4]; } u, w;
switch(sizeof(long double)) {
+ case 16:
+ w.bits[0] = w.bits[3] = 0;
+ w.d = 1.;
+ u.d = 3.;
+ w.d = w.d / u.d;
+ if (w.bits[0] && w.bits[3])
+ printf("cp x.ou0 x.out; cp xL.ou0 xL.out;"
+ " cp Q.ou1 Q.out; cp pftestQ.out pftest.out\n");
+ else
+ printf("cp x.ou0 x.out; cp xL.ou0 xL.out;"
+ " cp Q.ou0 Q.out; cp pftestx.out pftest.out\n");
+ break;
case 10:
case 12:
- printf("cp x.ou1 x.out; cp xL.ou1 xL.out; cp Q.ou0 Q.out\n");
- break;
- case 16:
- printf("cp x.ou0 x.out; cp xL.ou0 xL.out; cp Q.ou1 Q.out\n");
+ printf("cp x.ou1 x.out; cp xL.ou1 xL.out; cp Q.ou0 Q.out;"
+ " cp pftestx.out pftest.out\n");
break;
default:
- printf("cp x.ou0 x.out; cp xL.ou0 xL.out; cp Q.ou0 Q.out\n");
+ printf("cp x.ou0 x.out; cp xL.ou0 xL.out; cp Q.ou0 Q.out;"
+ " cp pftestx.out pftest.out\n");
}
return 0;
}
diff --git a/test/xsum0.out b/test/xsum0.out
index 3081e0a8722d..52b8a3e6040a 100644
--- a/test/xsum0.out
+++ b/test/xsum0.out
@@ -1,35 +1,41 @@
-README e3adb571 3095
-Qtest.c e8353ffc 5046
+README efba0d5d 3412
+Q.ou0 e4592b85 28742
+Q.ou1 ea0b344d 39572
+Qtest.c efe2b3f4 5116
+d.out f271efc9 28131
+dI.out d522eef 4369
+dIsi.out 1dd6d02f 4350
dItest.c e33800ce 2371
-ddtest.c f9d06e7b 4984
-dtest.c ee533ac3 4078
-dt.c 7eeda57 6384
-ftest.c ec8a6654 3999
-getround.c fe659fe7 2503
+dd.out e262456e 40923
+ddsi.out 1f94bbe2 10251
+ddtest.c ef71cbf3 4986
+dt.c e562c302 6808
+dtest.c 9a5d01 4080
+dtst.out e284ac98 23711
+f.out 9013e91 21537
+ftest.c 1c824a88 4001
+getround.c ee95ed1 2502
+makefile f714a641 5634
+pfLqtestnos ffb9723 99
+pftest.c ea314d7f 3452
+pftestQ.out 198434fd 830
+pftestx.out 1ccea5dd 788
+pftestLq.out 1691dbfc 845
+pftestnos ecbc9be6 101
+rtestnos f94bcdf6 336
strtoIdSI.c 7bfb88b 49
strtoIddSI.c 72e8852 50
strtodISI.c ed08b740 49
-strtodt.c aaf94bc 3330
+strtodt.c f1aa53af 3374
strtopddSI.c 13e7138d 50
strtorddSI.c f7e4b1d5 50
-xLtest.c f3f96ad1 4833
-xQtest.c efdea3a2 1549
-xtest.c ee81e661 4830
-rtestnos f94bcdf6 336
testnos e89999d6 485
testnos1 7e16229 294
-testnos3 fa5c8aca 11998
-dI.out d522eef 4369
-dIsi.out 1dd6d02f 4350
-ddsi.out 1f94bbe2 10251
-dd.out e262456e 40923
-dtst.out e284ac98 23711
-d.out f271efc9 28131
-f.out 9013e91 21537
+testnos3 f5ae7ef3 14403
x.ou0 1402f834 25372
-xL.ou0 faa3a741 26363
x.ou1 f1af5a00 34581
+xL.ou0 faa3a741 26363
xL.ou1 e349e5c 37165
-Q.ou0 e4592b85 28742
-Q.ou1 ea0b344d 39572
-makefile 13d36c85 5148
+xLtest.c ee11f673 4843
+xQtest.c efbe29be 1912
+xtest.c ec9f5deb 4834
diff --git a/test/xtest.c b/test/xtest.c
index 86d7fba01ce7..f5275f0b42ec 100644
--- a/test/xtest.c
+++ b/test/xtest.c
@@ -85,7 +85,7 @@ main(Void)
int i, dItry, ndig = 0, r = 1;
union { long double d; UShort bits[5]; } u, v[2];
- while(s = fgets(ibuf, sizeof(ibuf), stdin)) {
+ while((s = fgets(ibuf, sizeof(ibuf), stdin))) {
while(*s <= ' ')
if (!*s++)
continue;
@@ -96,7 +96,7 @@ main(Void)
continue;
case 'n':
i = s[1];
- if (i <= ' ' || i >= '0' && i <= '9') {
+ if (i <= ' ' || (i >= '0' && i <= '9')) {
ndig = atoi(s+1);
continue;
}