home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / fortran / 4231 < prev    next >
Encoding:
Internet Message Format  |  1992-11-08  |  1.9 KB

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