Path: utzoo!attcan!uunet!lll-winken!ames!mailrus!csd4.milw.wisc.edu!nic.MR.NET!umn-cs!victory!jot From: jot@victory.cray.com (Otto Tennant) Newsgroups: comp.lang.fortran Subject: Re: CFT/CFT77 gotcha Keywords: truncation 47 vs. 48 bits Message-ID: <12943@victory.cray.com> Date: 23 Jan 89 15:06:28 GMT References: <23252@beta.lanl.gov> Reply-To: jot@cray.com (Otto Tennant) Organization: Cray Research, Inc., Mendota Heights, MN Lines: 39 In article <23252@beta.lanl.gov> dd@beta.lanl.gov (Dan Davison) writes: > >I came across an interesting non-bug in CFT77 today. A program >fragment: > a = 6.0 > b = 3.0 > i = a / b > >gave the result "2" in CFT on a X/MP-48 and "1" in CFT77 on the >same machine. > CFT77 should have produced a warning message for the above fragment. CFT uses a method called "strong rounding" to compensate for integer truncation in instances such as the above. However, the code is generated only when the compiler is certain that a real quotient will be used in an integer context. Thus, quoting from an internal paper by Tim Peters, in the fragment Z = X/Y I = Z J = X/Y I will not necessarily be equal to J. Strong rounding doesn't work all of the time. In the paper, it is noted that "I = 100 - 52./2." produces "73" with strong rounding. It has been my experience that few, if any, programs when first run under CFT77 produce no warning messages of this sort. Again quoting, "NINT compiles to fast in-line code; its use should be encouraged." Regardless of compiler, a program which produces a warning message should be considered to be in error. It is just too risky to treat warning errors casually. Standard disclaimers.