[gambit-list] Compiler expansion for sqrt

Bradley Lucier lucier at math.purdue.edu
Sat May 19 23:28:35 EDT 2007


Marc:

The compiler can expand (sqrt x) as

(define (sqrt x)
   (cond ((##fixnum? x)
	 (if (and (##fixnum.<= 0 x)
		  (or (##not (##fixnum? 4294967296))          ; 32-bit fixnums
		      (##fixnum.<= x 4503599627370496)))
	     (##flonum->fixnum (##flonum.sqrt (##flonum.<-fixnum x)))
	     (##sqrt x)))
	((and (##flonum? x)
	      (##flonum.<= 0. x))
	 (##flonum.sqrt x))
	(else
	 (##sqrt x))))

It's very worthwhile for some programs (and some micro-benchmarks ;-).

Brad



More information about the Gambit-list mailing list