0.8.0.78.vector-nil-string.14:
[sbcl.git] / src / code / irrat.lisp
index b221854..68e5d9f 100644 (file)
@@ -14,8 +14,9 @@
 \f
 ;;;; miscellaneous constants, utility functions, and macros
 
-(defconstant pi 3.14159265358979323846264338327950288419716939937511L0)
-;(defconstant e 2.71828182845904523536028747135266249775724709369996L0)
+(defconstant pi
+  #!+long-float 3.14159265358979323846264338327950288419716939937511l0
+  #!-long-float 3.14159265358979323846264338327950288419716939937511d0)
 
 ;;; Make these INLINE, since the call to C is at least as compact as a
 ;;; Lisp call, and saves number consing to boot.
   "Return the logarithm of NUMBER in the base BASE, which defaults to e."
   (if base-p
       (cond
-       ((zerop base) base) ; ANSI spec
+       ((zerop base) 0f0) ; FIXME: type
        ((and (typep number '(integer (0) *))
              (typep base '(integer (0) *)))
         (coerce (/ (log2 number) (log2 base)) 'single-float))
                      (integer-length denominator))
                   (coerce (%log1p (coerce (- number 1) 'double-float))
                           'single-float)
-                  (coerce (- (log numerator) (log denominator))
-                             'single-float)))))
+                  (coerce (/ (- (log2 numerator) (log2 denominator))
+                             (log (exp 1.0d0) 2.0d0))
+                          'single-float)))))
        (((foreach single-float double-float))
         ;; Is (log -0) -infinity (libm.a) or -infinity + i*pi (Kahan)?
         ;; Since this doesn't seem to be an implementation issue
       ;; space 0 to get maybe-inline functions inlined
       (declare (optimize (speed 3) (space 0)))
     (cond ((> (abs x)
-             #-(or linux hpux) #.(/ (asinh most-positive-double-float) 4d0)
-             ;; This is more accurate under linux.
-             #+(or linux hpux) #.(/ (+ (log 2.0d0)
-                                       (log most-positive-double-float))
-                                    4d0))
-              (coerce-to-complex-type (float-sign x)
-                                      (float-sign y) z))
+             ;; FIXME: this form is hideously broken wrt
+             ;; cross-compilation portability.  Much else in this
+             ;; file is too, of course, sometimes hidden by
+             ;; constant-folding, but this one in particular clearly
+             ;; depends on host and target
+             ;; MOST-POSITIVE-DOUBLE-FLOATs being equal.  -- CSR,
+             ;; 2003-04-20
+             #.(/ (+ (log 2.0d0)
+                     (log most-positive-double-float))
+                  4d0))
+          (coerce-to-complex-type (float-sign x)
+                                  (float-sign y) z))
          (t
           (let* ((tv (%tan y))
                  (beta (+ 1.0d0 (* tv tv)))