Module Name: src
Committed By: mlelstv
Date: Sat Nov 19 12:46:41 UTC 2011
Modified Files:
src/tests/lib/libm: t_sqrt.c
Log Message:
The compiler is allowed to use intermediate higher precision for float
arithmetic, which may cause differences smaller than float precision
but still much larger than eps = 1e-30.
Forcing intermediate results to volatile variables removes the excess
precision.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libm/t_sqrt.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/lib/libm/t_sqrt.c
diff -u src/tests/lib/libm/t_sqrt.c:1.1 src/tests/lib/libm/t_sqrt.c:1.2
--- src/tests/lib/libm/t_sqrt.c:1.1 Sun Oct 16 08:25:40 2011
+++ src/tests/lib/libm/t_sqrt.c Sat Nov 19 12:46:41 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sqrt.c,v 1.1 2011/10/16 08:25:40 jruoho Exp $ */
+/* $NetBSD: t_sqrt.c,v 1.2 2011/11/19 12:46:41 mlelstv Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_sqrt.c,v 1.1 2011/10/16 08:25:40 jruoho Exp $");
+__RCSID("$NetBSD: t_sqrt.c,v 1.2 2011/11/19 12:46:41 mlelstv Exp $");
#include <atf-c.h>
#include <math.h>
@@ -177,7 +177,7 @@ ATF_TC_BODY(sqrtf_powf, tc)
#ifndef __vax__
const float x[] = { 0.0, 0.005, 1.0, 99.0, 123.123, 9999.9999 };
const float eps = 1.0e-30;
- float y, z;
+ volatile float y, z;
size_t i;
for (i = 0; i < __arraycount(x); i++) {
@@ -187,7 +187,7 @@ ATF_TC_BODY(sqrtf_powf, tc)
if (fabsf(y - z) > eps)
atf_tc_fail_nonfatal("sqrtf(%0.03f) != "
- "powf(%0.03f, 1/3)\n", x[i], x[i]);
+ "powf(%0.03f, 1/2)\n", x[i], x[i]);
}
#endif
}