Add a regression test for ldexp().
This commit is contained in:
parent
5579a03f91
commit
cf88227d9a
@ -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}
|
||||
|
14
regress/lib/libc/ldexp/Makefile
Normal file
14
regress/lib/libc/ldexp/Makefile
Normal file
@ -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>
|
92
regress/lib/libc/ldexp/expected
Normal file
92
regress/lib/libc/ldexp/expected
Normal file
@ -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
|
191
regress/lib/libc/ldexp/ldexp.c
Normal file
191
regress/lib/libc/ldexp/ldexp.c
Normal file
@ -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;
|
||||
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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user