<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Marc,<br><br>Sorry if my joke didn't come across as one. I am new to scheme.<br><br>If I understand you correctly, the calculations in this stmt will be performed with bignum arith?<br><br>(declare (flonum))<br>(if (> x 0.01)<br>  (* x a 3.0)<br>  (/ x a))<br><br>and to avoid that for max speed, i'd rewrite it as follows??<br><br>(declare (flonum))<br>(define x ..)<br>(define a ..)<br><br>(define p (* x a 3.0))<br>(define q (/ x a))<br>(define r (> x 0.01))<br>(if r p q)<br><br><br><br><div><div id="SkyDrivePlaceholder"></div>> Subject: Re: [gambit-list] decreasing GC<br>> From: feeley@iro.umontreal.ca<br>> Date: Wed, 24 Apr 2013 14:17:39 -0400<br>> CC: kumoyuki@gmail.com; gambit-list@iro.umontreal.ca<br>> To: zhenshen10@outlook.com<br>> <br>> <br>> On 2013-04-24, at 12:37 PM, Zhen Shen <zhenshen10@outlook.com> wrote:<br>> <br>> > Havens!! Do gambit users launch rockets into space, is that the reason for having bignum arithmetic by default??!<br>> <br>> I'm not sure if you mean that question as a criticism of Scheme, a criticism of Gambit, or an actual question (in which case the answer is yes).  It is not so much that bignum arithmetic is "on by default".  It is really a consequence of the language design which specifies that Scheme arithmetic corresponds to mathematics when operating on exact numbers.  There are plenty of languages to choose from if you prefer (expt 2 31) returning -2147483648 .<br>> <br>> > Oh, and speaking of "exact" arithmetic, I thought that was impossible cause digital computers cant store reals?<br>> > <br>> > Anyhow, thanks to your and brad's suggestions, I made significant improvements:<br>> > memory usage is 3GB (down from 18GB!) and execution time descreased by 80%. This is mostly due to the flonums.<br>> > <br>> > Now, doing (declare (flonum)) at the top level, does this stop gambit from boxing flonums across function calls?<br>> <br>> No, flonums are kept unboxed only within a basic-block of code (a block of code uninterrupted by a jump, such as an "if" or function call).  So it pays to think carefully about where floating point calculations are placed.  Sometimes it is beneficial to recompute a result if it prevents carrying an intermediate result accross a jump.<br>> <br>> Marc<br>> <br></div>                                           </div></body>
</html>