Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/lib/libc Add a regression test for ldexp().
details: https://anonhg.NetBSD.org/src/rev/d43b26b6760d
branches: trunk
changeset: 475946:d43b26b6760d
user: mycroft <mycroft%NetBSD.org@localhost>
date: Mon Aug 30 17:03:16 1999 +0000
description:
Add a regression test for ldexp().
diffstat:
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 deletions(-)
diffs (truncated from 326 to 300 lines):
diff -r 1b82320c7adb -r d43b26b6760d regress/lib/libc/Makefile
--- a/regress/lib/libc/Makefile Mon Aug 30 16:48:07 1999 +0000
+++ b/regress/lib/libc/Makefile Mon Aug 30 17:03:16 1999 +0000
@@ -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 -r 1b82320c7adb -r d43b26b6760d regress/lib/libc/ldexp/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/ldexp/Makefile Mon Aug 30 17:03:16 1999 +0000
@@ -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 <bsd.prog.mk>
diff -r 1b82320c7adb -r d43b26b6760d regress/lib/libc/ldexp/expected
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/ldexp/expected Mon Aug 30 17:03:16 1999 +0000
@@ -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 -r 1b82320c7adb -r d43b26b6760d regress/lib/libc/ldexp/ldexp.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/ldexp/ldexp.c Mon Aug 30 17:03:16 1999 +0000
@@ -0,0 +1,191 @@
+#include <math.h>
+#include <stdio.h>
+
+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;
Home |
Main Index |
Thread Index |
Old Index