Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!ucla-cs!zen!ucbvax!psw.DEC.COM!winalski From: winalski@psw.DEC.COM (Paul S. Winalski) Newsgroups: comp.os.vms Subject: Re: Bafflement (or, when 33554432 + 1 = 33554432) Message-ID: <8709192154.AA26147@decwrl.dec.com> Date: Sat, 19-Sep-87 20:40:00 EDT Article-I.D.: decwrl.8709192154.AA26147 Posted: Sat Sep 19 20:40:00 1987 Date-Received: Sun, 20-Sep-87 21:30:14 EDT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 22 You are being bitten by the precision limit for single-precision floating point (the VAX F-float data type). A FORTRAN variable declared simply REAL will be REAL*4, which VAX FORTRAN implements as F-floating. An F-floating number can have a very wide exponent range, but the mantissa only has six or so decimal digits of precision. Thus, when you say: a = 33554432 the resulting value of A will be 3.35544E+7, more or less. If you try adding 1.0 to this value, it winds up being a no-op because, when the two numbers are scaled for the addition, the 1.0 just falls off the end of the available precision. If you keep trying to add larger and larger values, eventually you hit one that is large enough to not scale off the low mantissa bit, and you will actually increment the number. In your case, this occurred at 4. The solution is to use double precision (D-float or G-float), which gives you 15 decimal digits of precision. Of course, the same problem occurs in Pascal because Pascal's single precision also uses F-float. --PSW