<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>This "Supercomputer Toolkit" looks pretty cool! I skimmed over the article, and will read it completely later on.&nbsp;</span><span style="background-color: transparent;">Am I understanding that this uses integer arithmetic? It said that it supported quad-precision 128-bit integers (four 32-bit integers concatenated).</span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>One of the cool things about Forth is that it uses "mixed-precision" integer arithmetic. For example, this is the
 famous star-slash scalar:</span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span style="background-color: transparent;">*/ &nbsp; &nbsp;( n1 n2 n3 -- (n1*n2)/n3 )</span><br></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>The clever thing here is that the intermediate value (n1*n2) is double-precision, although all of the inputs and the output are single-precision.</span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>We also have some that mix single-precision and double-precision inputs and outputs. For example, here are a
 few:</span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>m* &nbsp; &nbsp;( n1 n2 -- d ) This multiplies&nbsp;</span><span style="font-size: 12pt;">two single-precision and returns a double-precision, all signed.</span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>um* &nbsp; &nbsp;( u1 u2 -- ud ) This multiplies two single-precision and returns a double-precision, all unsigned.</span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span style="background-color: transparent;">um/mod &nbsp; &nbsp;( ud u1 -- urem uquot )&nbsp;</span><span
 style="background-color: transparent;">This divides a double-precision by a single--precision, and returns the remainder and quotient as single-precision, all unsigned.</span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span style="background-color: transparent;">fm/mod &nbsp; &nbsp;( d n1 -- nrem nquot ) This divides a double--precision by a single-precision, and returns the remainder and quotient as single-precision, all signed, with a floored division.</span></div><div style="background-color: transparent;"><span style="background-color: transparent;">sm/rem &nbsp; &nbsp;( d n1 -- nrem nquot ) This divides a double--precision by a single-precision, and returns the remainder and quotient as single-precision, all signed, with a symmetric division.</span></div><div style="color: rgb(0, 0, 0); font-size:
 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span style="background-color: transparent;">m*/ &nbsp; &nbsp;( d n1 n2 -- (d*n1)/n2 ) &nbsp;This is like */ except that it multiplies a double-precision by a single precision to get a triple-precision intermediate value, then divides that by n2 (which has to be positive) to return a double-precision quotient, all signed.</span><br></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;">I've heard of extension libraries being provided for Forth that allow for mixed-precision arithmetic of double-precision and
 quad-precision, although that is non-standard. Weirdly enough, ANS-Forth doesn't provide d/ ( d1 d2 -- dquot ). I complained about this to the Forth-200x committee but they wouldn't listen to me (it is rare that anybody ever does). I ended up providing this myself in my novice package, although this is written in Forth so as to be ANS-Forth compliant rather than in assembly-language for speed (this is one of the few parts of the novice package that I didn't write myself, as I got this code from somebody else). My own language that I'm inventing, which I call Straight Forth, will have separate stacks for single-precision and double-precision integers --- this will help to clean up the code a lot compared to ANS-Forth, in which single-precision and double-precision integers are mingled together on the same parameter stack --- I will also provide more numerical functions, including d/, that are missing from ANS-Forth.</div><div style="color: rgb(0, 0, 0);
 font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;">I'm not saying that numerical programming is impossible in Scheme. I'm just saying that Forth has always been oriented toward numerical programming of integers, and within the last couple decades of floating-point too. I would use Forth for any numerical program, especially one that also involves a DSL. That is me though --- Dmitry seems to be pretty committed to Racket, so I'll wish him luck at that --- Forth is pretty off-topic for the Racket mailing list, so I won't discuss it any further. I will mention, though, that when I discussed Forth's mixed-precision integer arithmetic on the Factor mailing list, Slava Pestov responded
 by upgrading Factor to support some of Forth's capability in this regard (this is one of the few cases in which anybody has listened to me and changed their language at my request) --- this was back in 2009 when I was still programming in Factor --- I have since dropped Factor because my own education wasn't sufficient for understanding the concepts, and I switched to Scheme which has more educational documentation available (such as SICP).</div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>regards --- Hugh</span></div><div style="color: rgb(0, 0, 0); font-size: 15.555556297302246px; font-family: 'times new roman', 'new
 york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div><br></div>  <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Joe Marshall &lt;jmarshall@alum.mit.edu&gt;<br> <b><span style="font-weight: bold;">To:</span></b> Hugh Aguilar &lt;hughaguilar96@yahoo.com&gt; <br><b><span style="font-weight: bold;">Cc:</span></b> "users@racket-lang.org" &lt;users@racket-lang.org&gt; <br> <b><span style="font-weight: bold;">Sent:</span></b> Wednesday, November 14, 2012 5:48 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [racket] 80-bit precision in Racket<br> </font> </div> <br>
<div id="yiv1788075954"><br><br><div class="yiv1788075954gmail_quote">On Tue, Nov 13, 2012 at 10:43 PM, Hugh Aguilar <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:hughaguilar96@yahoo.com" target="_blank" href="mailto:hughaguilar96@yahoo.com">hughaguilar96@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="yiv1788075954gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div><div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif;"><div class="yiv1788075954im"><div>&gt;&nbsp;<span style="font-size:12pt;">We are doing numerical&nbsp;</span><span style="font-size:12pt;">integration of celestial bodies over large periods of time&nbsp;</span><span style="font-size:12pt;">(100 years is a norm).</span></div>

<div style="font-style:normal;font-size:16px;background-color:transparent;"><br></div></div><div style="font-style:normal;font-size:16px;background-color:transparent;">

I'm new to Scheme, so I may be totally wrong about this --- but, isn't a numerical program like this exactly what Scheme is *not* designed for?</div></div></div></blockquote><div><br></div><div>The Supercomputer Toolkit (&nbsp;http://www.hpl.hp.com/techreports/94/HPL-94-30.html&nbsp;) was</div>

<div>designed for doing numerical integration of celestial bodies over large periods of time. &nbsp;</div><div><br></div><div>"The Toolkit's compiler uses a novel strategy based upon partial evaluation [7, 9]. This exploits the data-independence of typical numerical</div>

<div>algorithms to generate exceptionally efficient object code from source programs that are expressed in terms of highly abstract components written in</div><div>the Scheme dialect of Lisp [14]."</div><div><br></div>

<div>"The integrator and the force law were written as high level Scheme programs. The accumulation of position was implemented in</div><div>quad precision (128 bits), and the required quad precision operators were</div>

<div>written in Scheme."</div><div><br></div><div>"In hindsight, the use of quad precision appears to have been overly conservative for this</div><div>problem"</div><div><br></div></div>-- <br>~jrm<br>
</div><br><br> </div> </div>  </div></body></html>