[gambit-list] Simple benchmark of |->integer| and |->flonum| on integer, flonum and rational input. For the further if you have any idea of a definition faster than (inexact->exact (floor n)) feel free to share :)

Bradley Lucier lucier at math.purdue.edu
Wed Apr 24 20:31:18 EDT 2013


On Apr 24, 2013, at 5:17 PM, Mikael wrote:

> 
> I'd love to see the flonum to integer speed a bit higher (yellow above), I mean in C that's just  double d; int i = (int) d; .

If you want to do that, you can do (##flonum->fixnum d) (undocumented, internal function):

> (##flonum->fixnum 5.5)              
5
> (##flonum->fixnum -5.5)
-5

But that isn't floor; that doesn't work for large flonums.

If you want C, you can write C in Gambit.  Many people don't understand the semantics of the numerical operations in Scheme generally, or in Gambit in particular.

Brad




More information about the Gambit-list mailing list