home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!sol.ctr.columbia.edu!eff!world!ksr!tim
- From: tim@ksr.com (Tim Peters)
- Newsgroups: comp.lang.fortran
- Subject: Re: unformatted output
- Message-ID: <18290@ksr.com>
- Date: 6 Nov 92 16:00:32 EST
- References: <33492@adm.brl.mil> <Bx5IM3.9nF@news.cso.uiuc.edu> <Bx5s1u.C0J@pgroup.com> <KHB.92Nov3190132@chiba.Eng.Sun.COM>
- Sender: news@ksr.com
- Organization: Kendall Square Research Corp.
- Lines: 31
-
- In article <KHB.92Nov3190132@chiba.Eng.Sun.COM> khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup) writes:
- >In article <Bx5s1u.C0J@pgroup.com> lfm@pgroup.com (Larry Meadows) writes:
- > > IEEE standard guarantees that binary->decimal->binary is the identity
- > > if at least as many significant digits as specified the standard are
- > > written out. I believe it is 17 digits for double and 9 digits for
- > > single.
- >
- > Actually, a close reading of the standard reveals that an
- > implementation is free to do relatively poor rounding for large
- > numbers; this destroys the identity.
-
- Agree that an implementation is free to do less-than-perfect I/O
- conversions for large numbers, but the conversions have to be accurate
- enough in every case so that read(write(x)).eq.x always holds under round-
- to-nearest. From section 5.6 (Binary <-> Decimal Conversion) of 754-
- 1985:
-
- When rounding to nearest, conversion from binary to decimal and
- back to binary shall be the identity as long as the decimal
- string is carried to the maximum precision specified in Table 2,
- namely, 9 digits for single and 17 digits for double.
-
- Print fewer than that many decimal digits, and the identity won't hold in
- some cases even if all conversions are rounded perfectly; print at least
- that many decimal digits, and perfect rounding isn't needed to make the
- identity hold for all cases.
-
- sometimes-compromise-just-increases-confusion-ly y'rs - tim
-
- Tim Peters Kendall Square Research Corp
- tim@ksr.com, ksr!tim@uunet.uu.net
-