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,388fc53f584bd695 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!k17g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Fixed point constants issue Date: Mon, 27 Sep 2010 10:58:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <1f0l0baynq1x7$.phl9cqpwcr37.dlg@40tude.net> <8f7b0nF6hfU1@mid.individual.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1285610297 10296 127.0.0.1 (27 Sep 2010 17:58:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 27 Sep 2010 17:58:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k17g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:14280 Date: 2010-09-27T10:58:17-07:00 List-Id: On Sep 24, 2:38=A0pm, Jeffrey Carter wrote: > On 09/24/2010 07:43 AM, Markus Sch=F6pflin wrote: > > > > > > > > > Are you sure about that? Because I compiled and ran the following > > program with an Ada 83 compiler (DEC Ada) and I got a different result. > > Note that I modified the delta to 0.5 to avoid any issues resulting fro= m > > delta /=3D small. > > > ---%<--- > > with TEXT_IO; use TEXT_IO; > > > procedure FIXED_POINT > > is > > type ALTITUDE is delta 0.5 range 0.0 .. 50_000.0; > > > package ALTITUDE_IO is new FIXED_IO (ALTITUDE); > > > FEET_PER_METER : constant :=3D 0.3048; > > HEIGHT : constant :=3D 10; -- Feet > > > TEN_FEET_1 : constant :=3D HEIGHT * FEET_PER_METER; > > TEN_FEET_2 : constant ALTITUDE :=3D HEIGHT * FEET_PER_METER; > > begin > > ALTITUDE_IO.PUT (TEN_FEET_1); NEW_LINE; -- gives 3.0 > > ALTITUDE_IO.PUT (TEN_FEET_2); NEW_LINE; -- gives 5.0 (*) > > end FIXED_POINT; > > --->%--- > > > (*) This certainly looks like FEET_PER_METER is converted to ALTITUDE > > before doing the multiplication. > > That is interesting. I learned Ada 83 in 1984; I was explicitly taught th= at > static universal (sub)expressions were evaluated exactly by the compiler,= using > universal operations. For example, I was taught that in > > Pi : constant :=3D 3.14159; > > X : Float; > ... > Reduce : loop > =A0 =A0 exit Reduce when X < Pi / 2; > > =A0 =A0 X :=3D X - Pi / 2; > end loop Reduce; > > both occurrences of "Pi / 2" would be evaluated exactly by the compiler. = Perhaps > I was taught wrong. Hmmm... in looking into this, I bumped into AI83-165 which would make it appear that the use of Pi/2 in both occurrences is illegal. But maybe that AI got superseded by some other AI. I don't know. -- Adam