Skip to content
Snippets Groups Projects
Commit ce47dbf3 authored by ram's avatar ram
Browse files

Changed BASIC-COMPARE to optimize the case of comparing floats to 0. Changed

FLOAT-DIGITS to use new constants.  Macroized zerop, plusp, etc.
parent 677aa50a
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman (FAHLMAN@CMUC). ;;; Scott Fahlman (FAHLMAN@CMUC).
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.4 1990/07/06 21:22:32 wlott Exp $ ;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.5 1990/07/07 13:30:50 ram Exp $
;;; ;;;
;;; This file contains the definitions of most number functions. ;;; This file contains the definitions of most number functions.
;;; ;;;
...@@ -753,7 +753,9 @@ ...@@ -753,7 +753,9 @@
((double-float single-float) ((double-float single-float)
(,op x (coerce y 'double-float))) (,op x (coerce y 'double-float)))
(((foreach single-float double-float) rational) (((foreach single-float double-float) rational)
(,op (rational x) y)) (if (eql y 0)
(,op x (coerce 0 '(dispatch-type x)))
(,op (rational x) y)))
(((foreach bignum fixnum ratio) float) (((foreach bignum fixnum ratio) float)
(,op x (rational y))) (,op x (rational y)))
...@@ -1223,25 +1225,13 @@ ...@@ -1223,25 +1225,13 @@
;;;; Random number predicates: ;;;; Random number predicates:
(defun zerop (number) (macrolet ((frob (name doc)
"Returns T if number = 0, NIL otherwise." `(defun ,name (number) ,doc (,name number))))
(zerop number)) (frob zerop "Returns T if number = 0, NIL otherwise.")
(frob plusp "Returns T if number > 0, NIL otherwise.")
(defun plusp (number) (frob minusp "Returns T if number < 0, NIL otherwise.")
"Returns T if number > 0, NIL otherwise." (frob oddp "Returns T if number is odd, NIL otherwise.")
(plusp number)) (frob evenp "Returns T if number is even, NIL otherwise."))
(defun minusp (number)
"Returns T if number < 0, NIL otherwise."
(minusp number))
(defun oddp (number)
"Returns T if number is odd, NIL otherwise."
(oddp number))
(defun evenp (number)
"Returns T if number is even, NIL otherwise."
(evenp number))
;;; Float operations: ;;; Float operations:
...@@ -1293,8 +1283,8 @@ ...@@ -1293,8 +1283,8 @@
representation of it's argument. See Common Lisp: The Language representation of it's argument. See Common Lisp: The Language
by Guy Steele for more details." by Guy Steele for more details."
(number-dispatch ((f float)) (number-dispatch ((f float))
((single-float) 24) ((single-float) single-float-digits)
((double-float) 53))) ((double-float) double-float-digits)))
(defun float-precision (f) (defun float-precision (f)
"Returns a non-negative number of significant radix-b digits "Returns a non-negative number of significant radix-b digits
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment