humble beginnings of regression tests for libm functions: test for
a longstanding bug in round()/roundf() which I will pull in a fix for (from FreeBSD) in a minute
This commit is contained in:
parent
bd627359dd
commit
f0a00b4ec9
@ -1,8 +1,8 @@
|
||||
# $NetBSD: Makefile,v 1.19 2007/05/30 19:49:49 tls Exp $
|
||||
# $NetBSD: Makefile,v 1.20 2007/08/21 19:52:36 drochner Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
SUBDIR+= csu libc libevent libposix libpthread librt libutil
|
||||
SUBDIR+= csu libc libevent libm libposix libpthread librt libutil
|
||||
|
||||
.if (${MACHINE_CPU} != "alpha" && \
|
||||
${MACHINE_CPU} != "mips" && \
|
||||
|
5
regress/lib/libm/Makefile
Normal file
5
regress/lib/libm/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
# $NetBSD: Makefile,v 1.1 2007/08/21 19:52:36 drochner Exp $
|
||||
|
||||
SUBDIR= round
|
||||
|
||||
.include <bsd.subdir.mk>
|
10
regress/lib/libm/round/Makefile
Normal file
10
regress/lib/libm/round/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# $NetBSD: Makefile,v 1.1 2007/08/21 19:52:36 drochner Exp $
|
||||
|
||||
PROG= round
|
||||
LDADD+= -lm
|
||||
NOMAN=
|
||||
|
||||
regress: $(PROG)
|
||||
./$(PROG)
|
||||
|
||||
.include <bsd.prog.mk>
|
25
regress/lib/libm/round/round.c
Normal file
25
regress/lib/libm/round/round.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* $NetBSD: round.c,v 1.1 2007/08/21 19:52:36 drochner Exp $ */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* This tests for a bug in the initial implementation where precision
|
||||
* was lost in an internal substraction, leading to rounding
|
||||
* into the wrong direction.
|
||||
*/
|
||||
|
||||
/* 0.5 - EPSILON */
|
||||
#define VAL 0x0.7ffffffffffffcp0
|
||||
#define VALF 0x0.7fffff8p0
|
||||
|
||||
int main()
|
||||
{
|
||||
double a = VAL, b, c;
|
||||
float af = VALF, bf, cf;
|
||||
|
||||
b = round(a);
|
||||
bf = roundf(af);
|
||||
c = round(-a);
|
||||
cf = roundf(-af);
|
||||
return (b != 0 || bf != 0 || c != 0 || cf != 0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user