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!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!not-for-mail From: =?UTF-8?B?TWFya3VzIFNjaMO2cGZsaW4=?= Newsgroups: comp.lang.ada Subject: Re: Fixed point constants issue Date: Fri, 24 Sep 2010 16:43:29 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <1f0l0baynq1x7$.phl9cqpwcr37.dlg@40tude.net> <8f7b0nF6hfU1@mid.individual.net> NNTP-Posting-Host: hzAn46cwLozSmDBblnAvDQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 Xref: g2news1.google.com comp.lang.ada:14234 Date: 2010-09-24T16:43:29+02:00 List-Id: Forgive me for resurrecting an old thread, but when trying to understand the issue, I came up with more questions... Am 13.09.2010 22:35, schrieb Jeffrey Carter: > 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. 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. Another question regarding the implicit conversion from universal_real to ALTITUDE: Does ARM83-3.5.6 apply here? And what does this mean: "If the universal_real value is a safe number, the implicit conversion delivers the corresponding value; if it belongs to the range of safe numbers but is not a safe number, then the converted value can be any value within the range defined by the safe numbers next above and below the universal_real value." Is the compiler free to convert FEET_PER_METER to either 0.0 or 0.5? Regards, Markus