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-7-bit Path: g2news1.google.com!news4.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!panix!usenet.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newsgate.cuhk.edu.hk!news.netfront.net!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Fixed point constants issue Date: Mon, 13 Sep 2010 13:35:46 -0700 Organization: Netfront http://www.netfront.net/ Message-ID: References: <1f0l0baynq1x7$.phl9cqpwcr37.dlg@40tude.net> <8f7b0nF6hfU1@mid.individual.net> NNTP-Posting-Host: 75.211.119.37 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: adenine.netfront.net 1284410147 14507 75.211.119.37 (13 Sep 2010 20:35:47 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Mon, 13 Sep 2010 20:35:47 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100826 Thunderbird/3.0.7 In-Reply-To: <8f7b0nF6hfU1@mid.individual.net> Xref: g2news1.google.com comp.lang.ada:14057 Date: 2010-09-13T13:35:46-07:00 List-Id: On 09/13/2010 12:05 PM, Niklas Holsti wrote: > > The declaration of TEN_FEET_1 is a named-number declaration, so the > expression is evaluated using the "root" multiplication operator "*" > (Left : root_integer; Right : root_real) return root_real, which is done > at compile-time and exactly (with unlimited precision). Right. > > I would expect the compiler to evaluate the expression > > "HEIGHT * FEET_PER_METER" [for TEN_FEET_2] _before_ > > converting it to the appropriate fixed point type. > > The declaration of TEN_FEET_2 is an object declaration with type > Altitude, therefore the right-hand-side expression is expected to be of > type Altitude and so the "*" will be resolved to the Altitude > multiplication operator "*" (Left, Right : Altitude) return Altitude, > with result zero. More likely, function "*" (Left : in Integer; Right : in Altitude) return Altitude; [ARM 4.5.5(14)]. Feet_Per_Meter will be converted to Altitude before calling this function, resulting in a value of 0.0. Note that this changed between Ada 83 and Ada 95. In Ada 83, the expression is evaluated exactly at compile time using universal_real, just as for the named number. In Ada 95, this was changed to use the "*" function defined for Altitude. If the target compiler gives 3.0 as the value, then perhaps it is an Ada-83 compiler. There is a further wrinkle with the Ada 95 (and current Ada) rule. If "*" has not been overridden, this is a static expression and is evaluated at compile time. If "*" has been overridden, then this is not a static expression and it will be evaluated at run time. -- Jeff Carter "Mr. President, we must not allow a mine-shaft gap!" Dr. Strangelove 33 --- news://freenews.netfront.net/ - complaints: news@netfront.net ---