Elias Mårtenson <
lok...@gmail.com> writes:
> On Friday, 16 March 2012 05:21:08 UTC+8, Jack wrote:
>
>> I found the problem. Oddly enough, it was me.
>>
>> I left in a debugging statement with a ~F in it. That's where the floating point conversion blew up. Thanks for the assistance.
>
> That sounds very strange to me. Would you care to show the actual code?
(defun fact (x) (if (< x 1) 1 (* x (fact (1- x)))))
(format t "Result is : ~F~%" (fact 10))
(format t "Result is : ~F~%" (fact 100))
prints:
Result is : 3628800.0
Result is :
; Evaluation aborted on #<SYSTEM::SIMPLE-FLOATING-POINT-OVERFLOW
#x000334A53B78>.
> I can't think of any situation where just printing the value as a
> float would be able to impact the value itself (unless there is a
> problem with CCL's type inference).
What about when the integer is bigger than the biggest float
representable?
Floating point numbers go only up to very small number, like 10^646456992:
CL-USER> (values MOST-POSITIVE-SHORT-FLOAT MOST-POSITIVE-SINGLE-FLOAT
MOST-POSITIVE-DOUBLE-FLOAT MOST-POSITIVE-LONG-FLOAT)
3.4028s38
3.4028235E38
1.7976931348623157d308
8.8080652584198167656L646456992
10^646456992 is a small number it has only 646,456,992 digits! You can
easily compute bigger bignums.
And 32-bit IEEE-754 floats go only up to:
340282350000000000000000000000000000000
Which is a very small number! You only need 128 to represent it, that
is, it is a FIXNUM! Or could easily be a fixnum on a 128-bit
architecture. ;-)