diff options
| author | David Schultz <das@FreeBSD.org> | 2004-01-19 05:30:56 +0000 |
|---|---|---|
| committer | David Schultz <das@FreeBSD.org> | 2004-01-19 05:30:56 +0000 |
| commit | 24f285966ef8ac1ec10843758e5c29fc5614e81b (patch) | |
| tree | 98eae325dadc0d4f31a3b67ad757f3ef011b7871 /tools/regression/lib/libc/stdio/test-scanfloat.c | |
| parent | e249fdbedb56b95cab895e096b4b476633697117 (diff) | |
Notes
Diffstat (limited to 'tools/regression/lib/libc/stdio/test-scanfloat.c')
| -rw-r--r-- | tools/regression/lib/libc/stdio/test-scanfloat.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/regression/lib/libc/stdio/test-scanfloat.c b/tools/regression/lib/libc/stdio/test-scanfloat.c index 6666fd2e6bc4..791a33af2608 100644 --- a/tools/regression/lib/libc/stdio/test-scanfloat.c +++ b/tools/regression/lib/libc/stdio/test-scanfloat.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #include <float.h> +#include <ieeefp.h> #include <locale.h> #include <math.h> #include <stdio.h> @@ -62,9 +63,6 @@ main(int argc, char *argv[]) sscanf("3.141592653589793", "%lf", &d); assert(eq(DBL, d, 3.141592653589793)); - sscanf("3.14159265358979323846", "%Lg", &ld); - assert(eq(LDBL, ld, 3.14159265358979323846L)); - sscanf("1.234568e+06", "%E", &f); assert(eq(FLT, f, 1.234568e+06)); @@ -121,7 +119,10 @@ main(int argc, char *argv[]) assert(d == 0x90a.bcdefp+09); assert(strcmp(buf, "a") == 0); -#if LDBL_MANT_DIG > DBL_MANT_DIG +#if (LDBL_MANT_DIG > DBL_MANT_DIG) && !defined(__i386__) + sscanf("3.14159265358979323846", "%Lg", &ld); + assert(eq(LDBL, ld, 3.14159265358979323846L)); + sscanf(" 0X.0123456789abcdefffp-3g", "%Le%s", &ld, buf); assert(ld == 0x0.0123456789abcdefffp-3L); assert(strcmp(buf, "g") == 0); @@ -163,6 +164,16 @@ main(int argc, char *argv[]) sscanf("-nan", "%le", &d); assert(isnan(d)); + fpsetround(FP_RN); + + /* strtod() should round small numbers to 0. */ + sscanf("0x1.23p-5000", "%le", &d); + assert(d == 0.0); + + /* Extra digits in a denormal shouldn't break anything. */ + sscanf("0x1.2345678p-1050", "%le", &d); + assert(d == 0x1.234568p-1050); + printf("PASS scanfloat\n"); return (0); |
