From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4eca860272d4832b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s71.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Static vs dynamic evaluation anomaly? References: <12shen4qjhv41a7@corp.supernews.com> In-Reply-To: <12shen4qjhv41a7@corp.supernews.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s71 1170789420 12.201.97.213 (Tue, 06 Feb 2007 19:17:00 GMT) NNTP-Posting-Date: Tue, 06 Feb 2007 19:17:00 GMT Organization: AT&T ASP.att.net Date: Tue, 06 Feb 2007 19:17:01 GMT Xref: g2news2.google.com comp.lang.ada:9033 Date: 2007-02-06T19:17:01+00:00 List-Id: Matt Jaffe wrote: > A student of mine stumbled over a problem that I can reproduce but > can't explain. It manifests itself in the two different values computed > by two almost identical expressions when an integer variable is replaced > by an integer literal of the same value. Here's a sample output: > > The test pattern, X, is a modulo 2**6 integer = 31 or 2#11111# > > When J=0, X*2**J = 31 or 2#11111# but X*2**0 = 31 or 2#11111# > When J=1, X*2**J = 62 or 2#111110# but X*2**1 = 62 or 2#111110# > When J=2, X*2**J =124 or 2#1111100# but X*2**2 = 60 or 2#111100# > When J=3, X*2**J =248 or 2#11111000# but X*2**3 = 56 or 2#111000# > When J=4, X*2**J =240 or 2#11110000# but X*2**4 = 48 or 2#110000# > When J=5, X*2**J =224 or 2#11100000# but X*2**5 = 32 or 2#100000# > > Here are the relevant declarations: > > type Six_Bits is mod 2**6; > package Six_Bit_IO is new Ada.Text_IO.Modular_IO(Six_Bits); use > Six_Bit_IO; > X : Six_Bits := 31; I would need to see more to comment, but I suggest you eliminate all use clauses and see if that makes a difference. -- Jeff Carter "Pray that there's intelligent life somewhere up in space, 'cause there's bugger all down here on earth." Monty Python's Meaning of Life 61