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,UTF8 Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!news.musoftware.de!wum.musoftware.de!news.tornevall.net!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Fixed point constants issue Date: Fri, 24 Sep 2010 14:38:11 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <1f0l0baynq1x7$.phl9cqpwcr37.dlg@40tude.net> <8f7b0nF6hfU1@mid.individual.net> NNTP-Posting-Host: 344458f4d1c61620c6b10abe4013e680 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: 2789f949bf3f72a726d6350d4cad5efe X-Complaints-To: abuse@tornevall.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: X-UserIDNumber: 1738 X-Validate-Post: http://news.tornevall.net/validate.php?trace=2789f949bf3f72a726d6350d4cad5efe X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: g2news1.google.com comp.lang.ada:14245 Date: 2010-09-24T14:38:11-07:00 List-Id: On 09/24/2010 07:43 AM, Markus Schöpflin 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 from > delta /= 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 := 0.3048; > HEIGHT : constant := 10; -- Feet > > TEN_FEET_1 : constant := HEIGHT * FEET_PER_METER; > TEN_FEET_2 : constant ALTITUDE := 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 that static universal (sub)expressions were evaluated exactly by the compiler, using universal operations. For example, I was taught that in Pi : constant := 3.14159; X : Float; ... Reduce : loop exit Reduce when X < Pi / 2; X := X - Pi / 2; end loop Reduce; both occurrences of "Pi / 2" would be evaluated exactly by the compiler. Perhaps I was taught wrong. -- Jeff Carter "We use a large, vibrating egg." Annie Hall 44