Article View: comp.lang.fortran
Article #6515Precision of floating point multiply
From: Glen Herrmannsfeldt
Date: Sat, 27 Sep 2003 00:17
Date: Sat, 27 Sep 2003 00:17
50 lines
3861 bytes
3861 bytes
An article by W. Kahan titled "How Java's Floating-Point Hurts Everyone Everywhere" (and which describes much more than Java) includes a discussion about the results of floating point multiply. According to his description, until 1963 IBM Fortran compilers would generate double precision results for floating point multiply of two single precision numbers, at least when it was being summed into a double precision variable. He then explains that IBM changed this in IBSYS 13, anticipating S/360. As far as I can tell, the Fortran-66 standard requires a single precision product when multiplying single precision numbers, though I don't know how much impact IBM had on Fortran-66. The reason why this comment is surprising to me is that S/360 (along with S/370 and ESA/390) do not have a single precision multipy instruction with a single precision product. The product is always double precision. I have checked the code generated by both the G and H compilers, and both, after generating the multiply instruction generate at least two more instructions to truncate the product to single precision. It, then, seems unlikely to me that the change was made to accomodate S/360, when the S/360 hardware had exactly the opposite effect. I don't know what the status of Fortran-66 was in 1963, though, and what influence that may have had. As far as I know, Fortran still requires floating point multiply to generate a result with no more precision than the arguments that went into it. W.Kahan describes well the advantage of summing a double precision product of single precision arguments, yet the Fortran standard doesn't seem to follow it. (Someone with a more recent standard can comment on this.) The floating point rules in C (not crossposted to comp.lang.c) are more relaxed, and I believe that C compilers commonly do generate whatever results the hardware supplies. This, of course, can be confusing to programmers. PL/I has the MULTIPLY function where one can specify the desired result precision. At least one compiler I know of expands both operands before doing a double precision multiply when double precision is desired. If someone wanted to comment about other hardware or compilers in use in the 1960's and 1970's, that might also be useful. I would, in the end, like to thank W.Kahan for his unceasing drive to improve the results of floating point hardware and software, and hope for only constructive discussion of this problem. -- glen
Technical Details
Message-ID:
<dG4db.598668$uu5.97984@sccrnsc04>Path:
arc1-ca.pugleaf.net!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc04.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd4af,7830916812112af0,start X-Google-Attributes: gidfd4af,public X-Google-Thread: fd705,7830916812112af0,start X-Google-Attributes: gidfd705,public X-Google-Thread: 102b75,7830916812112af0,start X-Google-Attributes: gid102b75,public X-Google-Thread: 1094ba,7830916812112af0,start X-Google-Attributes: gid1094ba,public X-Google-ArrivalTime: 2003-09-26 17:17:14 PST Path: arc1-ca.pugleaf.net!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!sccrnsc04.POSTED!not-for-mail From: "Glen Herrmannsfeldt" <gah@ugcs.caltech.edu> Newsgroups: comp.lang.fortran,comp.arch,bit.listserv.ibm-main,alt.folklore.computers Subject: Precision of floating point multiply Lines: 54 X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Message-ID: <dG4db.598668$uu5.97984@sccrnsc04> NNTP-Posting-Host: 12.207.204.17 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc04 1064621833 12.207.204.17 (Sat, 27 Sep 2003 00:17:13 GMT) NNTP-Posting-Date: Sat, 27 Sep 2003 00:17:13 GMT Organization: Comcast Online Date: Sat, 27 Sep 2003 00:17:13 GMT