[gambit-list] number->integer
Taylor R Campbell
campbell at mumble.net
Wed Oct 29 19:30:22 EDT 2008
Date: Thu, 30 Oct 2008 08:37:32 +1000
From: Darren Baker <darren at wildfire.com.au>
This is no doubt Very Bad Practice but it's useful :)
(define flonum->fixnum
(c-lambda (double) int "___result = (int)___arg1;"))
That's absurd! Aside from the obvious absurdity of calling out to C
for this, it leads to nasal demons if the range of the argument's
integral part exceeds the range of C ints or Gambit fixnums. There is
a perfectly good standard procedure to obtain the nearest exact number
to an inexact one, which one may have obtained by rounding another
inexact number. This procedure is called INEXACT->EXACT.
More information about the Gambit-list
mailing list