Commit d4957beb authored by pfdietz's avatar pfdietz

Move rational-safely to ansi-aux.lsp to avoid gcl eval-when breakage

parent d34a8499
......@@ -1613,5 +1613,18 @@ the condition to go uncaught if it cannot be classified."
(return hi)
(setq lo mid))))))
\ No newline at end of file
(defun rational-safely (x)
"Rational a floating point number, making sure the rational
number isn't 'too big'. This is important in implementations such
as clisp where the floating bounds can be very large."
(assert (floatp x))
(multiple-value-bind (significand exponent sign)
(integer-decode-float x)
(let ((limit 1000)
(radix (float-radix x)))
(cond
((< exponent (- limit))
(* significand (expt radix (- limit)) sign))
((> exponent limit)
(* significand (expt radix limit) sign))
(t (rational x))))))
\ No newline at end of file
......@@ -19,23 +19,6 @@
(eqlt (abs x) (abs y)))
(t (eqlt x y))))
(eval-when (:compile-toplevel :load-toplevel :execute)
(defun rational-safely (x)
"Rational a floating point number, making sure the rational
number isn't 'too big'. This is important in implementations such
as clisp where the floating bounds can be very large."
(assert (floatp x))
(multiple-value-bind (significand exponent sign)
(integer-decode-float x)
(let ((limit 1000)
(radix (float-radix x)))
(cond
((< exponent (- limit))
(* significand (expt radix (- limit)) sign))
((> exponent limit)
(* significand (expt radix limit) sign))
(t (rational x)))))))
(defconstant +rational-most-negative-short-float+
(rational-safely most-negative-short-float))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment