[gambit-list] Compiler expansion for sqrt
Bradley Lucier
lucier at math.purdue.edu
Sun May 20 13:05:57 EDT 2007
On May 20, 2007, at 11:24 AM, Marc Feeley wrote:
> This definition is incorrect because:
>
> > (sqrt 17)
> 4
Sorry, what I needed was an expansion for integer-sqrt, which would
be something like
(define (integer-sqrt x)
(declare (standard-bindings)(extended-bindings)(block)(fixnum)
(not safe))
(if (and (##fixnum? x)
(##fixnum.<= 0 x)
(or (##not (##fixnum? 4294967296)) ; 32-bit fixnums
(##fixnum.<= x 4503599627370496)))
(##flonum->fixnum (##flonum.sqrt (##flonum.<-fixnum x)))
(##sqrt x)))
Brad
More information about the Gambit-list
mailing list