If you know your flonum is within the range of fixnums you can use the very efficient ##flonum->fixnum which will basically compile to a cast (correct me Marc if i'm wrong).<br><br>
<div class="gmail_quote">On Wed, Oct 29, 2008 at 8:20 PM, Darren Baker <span dir="ltr"><<a href="mailto:darren@wildfire.com.au">darren@wildfire.com.au</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi Taylor,<br><br>I do agree but it's only *mostly* absurd I would argue. :)<br><br>If I know I have a flonum within a known range, and I always want it as<br>
a fixnum, then this does the job, and I imagine skips a bunch of checks<br>that would be irrelevant in this case (pls correct me if wrong though!)<br><br>If you use (##c-code ... ) inline then the C callout is gone...  and on<br>
GCC / Intel the conversion will compile to a cvttsd2si instruction.<br><br>I am just putting a pragmatic / performance view here, it's definitely<br>not elegant.<br><br>Obviously if inexact->exact has higher performance, eg because it's an<br>
optimizable intrinsic, then this method is categorically rubbish. :)  I<br>haven't checked yet though.<br><br>Cheers,<br>Darren<br>
<div class="Ih2E3d"><br><br><br>Taylor R Campbell wrote:<br>>    Date: Thu, 30 Oct 2008 08:37:32 +1000<br>>    From: Darren Baker <<a href="mailto:darren@wildfire.com.au">darren@wildfire.com.au</a>><br>><br>
>    This is no doubt Very Bad Practice but it's useful :)<br>><br>>    (define flonum->fixnum<br>>        (c-lambda (double) int "___result = (int)___arg1;"))<br>><br>> That's absurd!  Aside from the obvious absurdity of calling out to C<br>
> for this, it leads to nasal demons if the range of the argument's<br>> integral part exceeds the range of C ints or Gambit fixnums.  There is<br>> a perfectly good standard procedure to obtain the nearest exact number<br>
> to an inexact one, which one may have obtained by rounding another<br>> inexact number.  This procedure is called INEXACT->EXACT.<br>><br>><br>><br><br></div>
<div class="Ih2E3d">--<br>Darren Baker<br>CEO, CTO<br>Wildfire Studios Pty. Ltd.<br></div>Ph: +61 7 3844 1000<br>Fax: +61 7 3844 8970<br><a href="http://www.wildfire.com.au/" target="_blank">www.wildfire.com.au</a><br><br>
The information in this message is confidential and may be legally<br>privileged.  It is intended solely for the addressee.  Access to this<br>message by anyone else is unauthorised.  If you are not the intended<br>recipient,  any disclosure,  copying or distribution of the message,  or<br>
any action taken by you in reliance on it,  is prohibited and may be<br>unlawful.  If you have received this message in error,  please delete it<br>and contact the sender immediately.  Thank you.<br>
<div>
<div></div>
<div class="Wj3C7c"><br>_______________________________________________<br>Gambit-list mailing list<br><a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br><a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br></div></div></blockquote></div><br>