On Wednesday 05 April 2006 00:28, John Wiseman wrote:
> In SBCL 0.9.10, attempting to compile the following function results
> in a type error:
>
> (defun intbitstofloat (bits)
> (let* ((s (if (=3D (ash bits 31) 0) 1 1))
> (e (logand (ash bits 23) #xff))
> (m (if (=3D e 0)
> (ash (logand bits #x7fffff) 1)
> (logior (logand bits #x7fffff) #x800000))))
> (float (* s m (expt 2 ( e 150))))))
>
> The error I get is this:
>
> debugger invoked on a SIMPLETYPEERROR:
> Too large to be represented as a SINGLEFLOAT:
> 680564693277057719623408366969033850880
>
> Type HELP for debugger help, or (SBEXT:QUIT) to exit from SBCL.
>
> restarts (invokable by number or by possiblyabbreviated name):
> 0: [ABORT] Exit debugger, returning to top level.
>
> ((LABELS SBBIGNUM::CHECKEXPONENT)
> #<unavailable argument>
> #<unavailable argument>
> #<unavailable argument>)
>
> Am I doing anything wrong?
Nope. A fix was committed as 0.9.11.22.
This distilled test case shows what went wrong more clearly:
(defun foo (n)
(declare (type (integer * #.(expt 2 300)) n))
(float n))
N is known to be < (expt 2 300). Then it tries to coerce the upper limit=20
to singlefloat when deriving the floatness of N at (FLOAT N).
Cheers, G=E1bor
>
>
> Thanks,
> John
