Skip to content
Snippets Groups Projects
Commit d4957beb authored by pfdietz's avatar pfdietz
Browse files

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

parent d34a8499
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
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