From cf88227d9a95434addc1f3b1541a0b2d2cabc6b4 Mon Sep 17 00:00:00 2001 From: mycroft Date: Mon, 30 Aug 1999 17:03:16 +0000 Subject: [PATCH] Add a regression test for ldexp(). --- regress/lib/libc/Makefile | 5 +- regress/lib/libc/ldexp/Makefile | 14 +++ regress/lib/libc/ldexp/expected | 92 +++++++++++++++ regress/lib/libc/ldexp/ldexp.c | 191 ++++++++++++++++++++++++++++++++ 4 files changed, 301 insertions(+), 1 deletion(-) create mode 100644 regress/lib/libc/ldexp/Makefile create mode 100644 regress/lib/libc/ldexp/expected create mode 100644 regress/lib/libc/ldexp/ldexp.c diff --git a/regress/lib/libc/Makefile b/regress/lib/libc/Makefile index cdba3135091d..383996005d5e 100644 --- a/regress/lib/libc/Makefile +++ b/regress/lib/libc/Makefile @@ -1,9 +1,12 @@ -# $NetBSD: Makefile,v 1.11 1999/02/04 18:58:33 is Exp $ +# $NetBSD: Makefile,v 1.12 1999/08/30 17:03:16 mycroft Exp $ SUBDIR+= _setjmp db regex setjmp sigsetjmp time .if (${MACHINE_ARCH} != "arm32" && ${MACHINE_ARCH} != "vax") SUBDIR+= ieeefp .endif +.if (${MACHINE_ARCH} != "vax") +SUBDIR+= ldexp +.endif .if exists(arch/${MACHINE_ARCH}) SUBDIR+= arch/${MACHINE_ARCH} diff --git a/regress/lib/libc/ldexp/Makefile b/regress/lib/libc/ldexp/Makefile new file mode 100644 index 000000000000..b998b4056df2 --- /dev/null +++ b/regress/lib/libc/ldexp/Makefile @@ -0,0 +1,14 @@ +# $NetBSD: Makefile,v 1.1 1999/08/30 17:03:17 mycroft Exp $ + +PROG= ldexp +MKMAN= no + +regress: ${PROG} + @./${PROG} >output + @if ! cmp -s ${.CURDIR}/expected output; then \ + echo "FAILED"; \ + else \ + echo "PASSED"; \ + fi + +.include diff --git a/regress/lib/libc/ldexp/expected b/regress/lib/libc/ldexp/expected new file mode 100644 index 000000000000..32ba3e42ff05 --- /dev/null +++ b/regress/lib/libc/ldexp/expected @@ -0,0 +1,92 @@ +basics: + 32 +4.4942328371557897693233e+307 +4.4942328371557897693233e+307 +8.9884656743115795386465e+307 +8.9884656743115795386465e+307 +8.9884656743115795386465e+307 + 0.03125 +4.4501477170144027661805e-308 +4.4501477170144027661805e-308 +2.2250738585072013830902e-308 +2.2250738585072013830902e-308 +2.2250738585072013830902e-308 + 1 + 1 + +zero: + 0 + 0 + 0 + 0 + 0 + 0 + 0 + +infinity: + Inf + Inf + Inf + -Inf + -Inf + -Inf + +overflow: + Inf + Inf + Inf + Inf + -Inf + -Inf + -Inf + -Inf + +denormal: +1.1125369292536006915451e-308 +1.1125369292536006915451e-308 +1.1125369292536006915451e-308 +5.5626846462680034577256e-309 +4.9406564584124654417657e-324 +-1.1125369292536006915451e-308 +-1.1125369292536006915451e-308 +-1.1125369292536006915451e-308 +-5.5626846462680034577256e-309 +-4.9406564584124654417657e-324 + +underflow: + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + +denormal, large exponent: + 0.0625 + 0.125 + 0.25 + 0.5 + 1 + 2 + 4 + 4096 + 4194304 + 4294967296 + 4722366482869645213696 +5.9863107065073783529623e+51 +7.5885503602567541832791e+81 +9.6196304190416209014353e+111 +1.2194330274671844653834e+142 +1.5458150092069033378781e+172 +1.9595533242629369747791e+202 +2.4840289476811342962384e+232 +3.1488807865122869393369e+262 +3.9916806190694396233127e+292 +2.808895523222368605827e+306 +5.6177910464447372116541e+306 +1.1235582092889474423308e+307 +2.2471164185778948846616e+307 +4.4942328371557897693233e+307 +8.9884656743115795386465e+307 diff --git a/regress/lib/libc/ldexp/ldexp.c b/regress/lib/libc/ldexp/ldexp.c new file mode 100644 index 000000000000..b5cbc6fd2f97 --- /dev/null +++ b/regress/lib/libc/ldexp/ldexp.c @@ -0,0 +1,191 @@ +#include +#include + +int +main() +{ + double v; + int e; + +#define FORMAT "%23.23lg\n" + + printf("basics:\n"); + v = 1.0; e = 5; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = 1022; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1023); e = -1; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = 1023; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1022); e = 1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1022); e = 2045; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = -5; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = -1021; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1022); e = 1; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = -1022; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1021); e = -1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1023); e = -2045; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1023); e = -1023; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1022); e = 1022; + printf(FORMAT, ldexp(v, e)); + printf("\n"); + + printf("zero:\n"); + v = 0.0; e = -1; + printf(FORMAT, ldexp(v, e)); + v = 0.0; e = 0; + printf(FORMAT, ldexp(v, e)); + v = 0.0; e = 1; + printf(FORMAT, ldexp(v, e)); + v = 0.0; e = 1024; + printf(FORMAT, ldexp(v, e)); + v = 0.0; e = 1025; + printf(FORMAT, ldexp(v, e)); + v = 0.0; e = -1023; + printf(FORMAT, ldexp(v, e)); + v = 0.0; e = -1024; + printf(FORMAT, ldexp(v, e)); + printf("\n"); + + printf("infinity:\n"); + v = ldexp(1.0, 1024); e = -1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1024); e = 0; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1024); e = 1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, 1024); e = -1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, 1024); e = 0; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, 1024); e = 1; + printf(FORMAT, ldexp(v, e)); + printf("\n"); + + printf("overflow:\n"); + v = 1.0; e = 1024; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1023); e = 1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1022); e = 2046; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = 1025; + printf(FORMAT, ldexp(v, e)); + v = -1.0; e = 1024; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, 1023); e = 1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, -1022); e = 2046; + printf(FORMAT, ldexp(v, e)); + v = -1.0; e = 1025; + printf(FORMAT, ldexp(v, e)); + printf("\n"); + + printf("denormal:\n"); + v = 1.0; e = -1023; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1022); e = -1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1023); e = -2046; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = -1024; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = -1074; + printf(FORMAT, ldexp(v, e)); + v = -1.0; e = -1023; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, -1022); e = -1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, 1023); e = -2046; + printf(FORMAT, ldexp(v, e)); + v = -1.0; e = -1024; + printf(FORMAT, ldexp(v, e)); + v = -1.0; e = -1074; + printf(FORMAT, ldexp(v, e)); + printf("\n"); + + printf("underflow:\n"); + v = 1.0; e = -1075; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1074); e = -1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, 1023); e = -2098; + printf(FORMAT, ldexp(v, e)); + v = 1.0; e = -1076; + printf(FORMAT, ldexp(v, e)); + v = -1.0; e = -1075; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, -1074); e = -1; + printf(FORMAT, ldexp(v, e)); + v = ldexp(-1.0, 1023); e = -2098; + printf(FORMAT, ldexp(v, e)); + v = -1.0; e = -1076; + printf(FORMAT, ldexp(v, e)); + printf("\n"); + + printf("denormal, large exponent:\n"); + v = ldexp(1.0, -1028); e = 1024; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1025; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1026; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1027; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1028; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1029; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1030; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1040; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1050; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1060; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1100; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1200; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1300; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1400; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1500; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1600; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1700; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1800; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 1900; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 2000; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 2046; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 2047; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 2048; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 2049; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 2050; + printf(FORMAT, ldexp(v, e)); + v = ldexp(1.0, -1028); e = 2051; + printf(FORMAT, ldexp(v, e)); + + exit(0); +}