On Wed, May 29, 2013 at 08:34:57AM +0200, Sven Hartrumpf wrote: > Tue, 28 May 2013 23:25:35 +0200, Peter.Bex wrote: > > For now I'd say this is a problem with your particular gcc version. > > If you or someone else can reproduce this and come up with a patch > > that would be great. > > I know this problem for a year or so (gcc 4.7.N, gcc 4.8.N; C optimization -O2 > or higher; 32bit build on 64bit Linux boxes). > I attach a simple patch to this mail (five tests must be made via > number->string). > I feel better now because I can test with "make check" again :-)
This patch should fix it, but it does in a roundabout way: converting the number to a string causes it to lose precision because of the default value of (flonum-print-precision). It's more explicit to check whether the two values lie within an epsilon of eachother, like the test egg does. Could you try whether "make check" on a -O3-compiled CHICKEN succeeds with the attached patch? Cheers, Peter -- http://www.more-magic.net
>From d4f4ed53a292de6b25b64e7e1e2251bed06f92ff Mon Sep 17 00:00:00 2001 From: Peter Bex <[email protected]> Date: Wed, 29 May 2013 19:05:32 +0200 Subject: [PATCH] Use inexact comparison for flonum tests. GCC optimizes trig functions (by inlining? pre-calculating?), which causes answers to be slightly different from the libc implementation. Thanks to John Long for reporting and Sven Hartrumpf for initial patch. --- tests/library-tests.scm | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/tests/library-tests.scm b/tests/library-tests.scm index 12d96b5..7cfca2c 100644 --- a/tests/library-tests.scm +++ b/tests/library-tests.scm @@ -207,28 +207,31 @@ ;; fp-math -(assert (= (sin 42.0) (fpsin 42.0))) -(assert (= (cos 42.0) (fpcos 42.0))) -(assert (= (tan 42.0) (fptan 42.0))) -(assert (= (asin 0.5) (fpasin 0.5))) -(assert (= (acos 0.5) (fpacos 0.5))) -(assert (= (atan 0.5) (fpatan 0.5))) -(assert (= (atan 42.0 1.2) (fpatan2 42.0 1.2))) -(assert (= (atan 42.0 1) (fpatan2 42.0 1.0))) -(assert (= (atan 42 1.0) (fpatan2 42.0 1.0))) -(assert (= (exp 42.0) (fpexp 42.0))) -(assert (= (log 42.0) (fplog 42.0))) -(assert (= (expt 42.0 3.5) (fpexpt 42.0 3.5))) -(assert (= (sqrt 42.0) (fpsqrt 42.0))) -(assert (= 43.0 (fpround 42.5))) -(assert (= -43.0 (fpround -42.5))) -(assert (= 42.0 (fpround 42.2))) -(assert (= 42.0 (fptruncate 42.5))) -(assert (= -42.0 (fptruncate -42.5))) -(assert (= 42.0 (fpfloor 42.2))) -(assert (= -43.0 (fpfloor -42.5))) -(assert (= 43.0 (fpceiling 42.5))) -(assert (= -42.0 (fpceiling -42.2))) +(define (inexact= a b) + (< (abs (- 1 (abs (/ a b)))) 1e-10)) + +(assert (inexact= (sin 42.0) (fpsin 42.0))) +(assert (inexact= (cos 42.0) (fpcos 42.0))) +(assert (inexact= (tan 42.0) (fptan 42.0))) +(assert (inexact= (asin 0.5) (fpasin 0.5))) +(assert (inexact= (acos 0.5) (fpacos 0.5))) +(assert (inexact= (atan 0.5) (fpatan 0.5))) +(assert (inexact= (atan 42.0 1.2) (fpatan2 42.0 1.2))) +(assert (inexact= (atan 42.0 1) (fpatan2 42.0 1.0))) +(assert (inexact= (atan 42 1.0) (fpatan2 42.0 1.0))) +(assert (inexact= (exp 42.0) (fpexp 42.0))) +(assert (inexact= (log 42.0) (fplog 42.0))) +(assert (inexact= (expt 42.0 3.5) (fpexpt 42.0 3.5))) +(assert (inexact= (sqrt 42.0) (fpsqrt 42.0))) +(assert (inexact= 43.0 (fpround 42.5))) +(assert (inexact= -43.0 (fpround -42.5))) +(assert (inexact= 42.0 (fpround 42.2))) +(assert (inexact= 42.0 (fptruncate 42.5))) +(assert (inexact= -42.0 (fptruncate -42.5))) +(assert (inexact= 42.0 (fpfloor 42.2))) +(assert (inexact= -43.0 (fpfloor -42.5))) +(assert (inexact= 43.0 (fpceiling 42.5))) +(assert (inexact= -42.0 (fpceiling -42.2))) (assert (not (fpinteger? 2.3))) (assert (fpinteger? 1.0)) -- 1.8.2.3
_______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
