[racket] Optimization; converting 'Float' to 'Fixnum' in Typed Racket

From: SF (sf.rom17 at gmail.com)
Date: Sat Feb 18 22:39:08 EST 2012

On Sat, Feb 18, 2012 at 9:18 PM, Robby Findler wrote:
> I'm not sure of the precise answer, but I don't think that all floats
> (even the integers) have a corresponding fixnum.

My C brain wonders why I can't just cast it to get the lower bits, I
don't care about overflow.

Using fixnum? does indeed work, just far too slowly. Still, good to
know. I didn't think of using Typed Racket like that.

I should mention that this is the best method I've found so far:

(: float->int (Float -> Integer))
(define (float->int x)
 (floor (inexact->exact (floor x))))   ; both floors are necessary

Posted on the users mailing list.