From 949acab5719c22e51a45a936271b46b04edaa8ac Mon Sep 17 00:00:00 2001 From: Raymond Toy <toy.raymond@gmail.com> Date: Fri, 20 Dec 2013 16:06:40 -0800 Subject: [PATCH] For dd-%%sin, return x if x is small enough. (Makes sin(-0w0) be -0w0). --- src/code/irrat-dd.lisp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/code/irrat-dd.lisp b/src/code/irrat-dd.lisp index 170bc06a9..6661f2b1c 100644 --- a/src/code/irrat-dd.lisp +++ b/src/code/irrat-dd.lisp @@ -1000,8 +1000,11 @@ pi/4 11001001000011111101101010100010001000010110100011000 010001101001100010 (declare (type (double-double-float -1w0 1w0) x) (optimize (speed 2) (space 0) (inhibit-warnings 3))) - (let ((x2 (* x x))) - (+ x (* x (* x2 (poly-eval x2 sincof)))))) + (if (< (abs (double-double-hi x)) + (scale-float 1d0 -52)) + x + (let ((x2 (* x x))) + (+ x (* x (* x2 (poly-eval x2 sincof))))))) ;; cos(x) = 1 - .5 x^2 + x^2 (x^2 P(x^2)) ;; Theoretical peak relative error = 2.1e-37, -- GitLab