Article View: comp.lang.fortran
Article #6519Re: Precision of floating point multiply
From: robin
Date: Sat, 27 Sep 2003 14:18
Date: Sat, 27 Sep 2003 14:18
67 lines
4394 bytes
4394 bytes
"Glen Herrmannsfeldt" <gah@ugcs.caltech.edu> writes: > 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. While this is true, it is also true that subsequent single-precision operations using the result will use only the single-precision product. Furthermore, storing the result into a single-precision variable will store only the single-precision product. To store a double-precision product, an STE will do, followed by a MVC STE+4(4),=F'0', or SDR 0,0 LER 0,4 STD 0, result The sequence SDR 0,0 LE 0,4 will convert the DP FPR 4 to single prec. for subsequent use with DP operands. > 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. The intrinsic DPROD will generate a DP product from SP arguments. > 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.) > > 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:
<h%gdb.126241$bo1.40978@news-server.bigpond.net.au>Path:
arc1-ca.pugleaf.net!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.mathworks.com!lon-transit.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!53ab2750!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd4af,7830916812112af0 X-Google-Attributes: gidfd4af,public X-Google-Thread: fd705,7830916812112af0 X-Google-Attributes: gidfd705,public X-Google-Thread: f8131,860da5e114d00659,start X-Google-Attributes: gidf8131,public X-Google-Thread: 102b75,7830916812112af0 X-Google-Attributes: gid102b75,public X-Google-Thread: 101deb,860da5e114d00659,start X-Google-Attributes: gid101deb,public X-Google-Thread: 1094ba,7830916812112af0 X-Google-Attributes: gid1094ba,public X-Google-ArrivalTime: 2003-09-27 07:20:13 PST Path: arc1-ca.pugleaf.net!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.mathworks.com!lon-transit.news.telstra.net!news.telstra.net!news-server.bigpond.net.au!53ab2750!not-for-mail From: robin <robin_v@bigpond.mapson.com> Newsgroups: comp.lang.fortran,comp.lang.asm370,comp.lang.pl1,comp.arch,bit.listserv.ibm-main,alt.folklore.computers Subject: Re: Precision of floating point multiply Lines: 67 Message-ID: <h%gdb.126241$bo1.40978@news-server.bigpond.net.au> Date: Sat, 27 Sep 2003 14:18:53 GMT NNTP-Posting-Host: 144.139.71.76 X-Complaints-To: abuse@bigpond.net.au X-Trace: news-server.bigpond.net.au 1064672333 144.139.71.76 (Sun, 28 Sep 2003 00:18:53 EST) NNTP-Posting-Date: Sun, 28 Sep 2003 00:18:53 EST Organization: BigPond Internet Services