From 24511623e8c3ba1752339d2613bbd18ef27859b0 Mon Sep 17 00:00:00 2001 From: Raymond Toy <toy.raymond@gmail.com> Date: Sat, 20 Sep 2014 13:50:47 -0700 Subject: [PATCH] Add fdlibm's log10. * src/code/irrat.lisp: * Define %log10 to use fdlibm's log10 * src/lisp/GNUmakefile * Compile e_log10 * tests/trig.lisp * Add tests for %log10. --- src/code/irrat.lisp | 2 +- src/lisp/GNUmakefile | 1 + tests/trig.lisp | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/code/irrat.lisp b/src/code/irrat.lisp index 2591907ae..61d43146c 100644 --- a/src/code/irrat.lisp +++ b/src/code/irrat.lisp @@ -81,7 +81,7 @@ ;;; Exponential and Logarithmic. (def-math-rtn ("__ieee754_exp" %exp) 1) (def-math-rtn ("__ieee754_log" %log) 1) -(def-math-rtn "log10" 1) +(def-math-rtn ("__ieee754_log10" %log10) 1) (def-math-rtn ("__ieee754_pow" %pow) 2) #-(or x86 sparc-v7 sparc-v8 sparc-v9) diff --git a/src/lisp/GNUmakefile b/src/lisp/GNUmakefile index c557d3be4..d0d61043e 100644 --- a/src/lisp/GNUmakefile +++ b/src/lisp/GNUmakefile @@ -12,6 +12,7 @@ FDLIBM = k_sin.c k_cos.c k_tan.c s_sin.c s_cos.c s_tan.c sincos.c \ e_acosh.c s_asinh.c e_atanh.c \ e_atan2.c \ e_rem_pio2.c k_rem_pio2.c \ + e_log10.c \ setexception.c SRCS = lisp.c coreparse.c alloc.c monitor.c print.c interr.c \ diff --git a/tests/trig.lisp b/tests/trig.lisp index 861a298a9..cdebe3973 100644 --- a/tests/trig.lisp +++ b/tests/trig.lisp @@ -1006,3 +1006,24 @@ (assert-true (ext:float-nan-p (kernel:%atan *qnan*))) (kernel::with-float-traps-masked (:invalid) (assert-true (ext:float-nan-p (kernel:%atan *snan*))))) + +(define-test %log10.exceptions + (:tag :fdlibm) + ;; %log10(2^k) = k + (dotimes (k 23) + (assert-equalp k + (kernel:%log10 (float (expt 10 k) 1d0)))) + (assert-error 'division-by-zero + (kernel:%log10 0d0)) + (assert-error 'floating-point-invalid-operation + (kernel:%log10 -1d0)) + (assert-true (ext:float-nan-p (kernel:%log10 *qnan*))) + (assert-equal ext:double-float-positive-infinity + (kernel:%log10 ext:double-float-positive-infinity)) + (kernel::with-float-traps-masked (:divide-by-zero) + (assert-equal ext:double-float-negative-infinity + (kernel:%log10 0d0)) + (assert-equal ext:double-float-negative-infinity + (kernel:%log10 -0d0))) + (kernel::with-float-traps-masked (:invalid) + (assert-true (ext:float-nan-p (kernel:%log10 -1d0))))) -- GitLab