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: a07f3367d7,6fabd104d18f3943 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!newsfeed.straub-nv.de!news.albasani.net!not-for-mail From: Dirk Herrmann Newsgroups: comp.lang.ada Subject: Re: conversions between fixed-point types Date: Sat, 26 Sep 2009 16:31:57 +0200 Organization: albasani.net Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net P5xj5azpFItU53Xr8iesQAZn3q8JjCa1P1kweWW/XCm4mYVV4o0KL0Q8RI/9hfVlyFVGf81L8u+2zpXVqtDGeUfIwYqBB1Ts5sdA3Dz8ELLk8zrCCkGmqPPM9pBBKAcd X-Complaints-To: abuse@albasani.net NNTP-Posting-Date: Sat, 26 Sep 2009 14:31:57 +0000 (UTC) X-User-ID: CHsYciaMQVBG6I0W1zRVS+fvOVAvgkMxs5qTKfiQZ7aAlfDRDusXSkUTkR9q+aYoOnvYgF9pmZlFqvexIRseew== In-Reply-To: Cancel-Lock: sha1:e35lyK/n7O6meyAVFYui63cLgnE= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) X-NNTP-Posting-Host: ivBtIt//BIEpzOnojq0PuaDMO9GKpm8m0Z5nTL8QIQg= Xref: g2news2.google.com comp.lang.ada:8483 Date: 2009-09-26T16:31:57+02:00 List-Id: Adam Beneschan wrote: > So I guess whether this is a GNAT bug or not depends on > FpB'Machine_Rounds. If it's TRUE, the first two expressions are > computed incorrectly, but if it's FALSE, this seemingly anomalous > result is allowed. I checked that T'Machine_Rounds is FALSE for FpA and FpB. Thus, according to your analysis the result should be OK with respect to the RM. > Also, it's clear that static expressions need to round or truncate to > a multiple of the 'Small if they're not part of a larger static > expression. But I'm not sure what this should do: > > FpA'Image (FpA (FpB' (-1.5))) > > Here, FpB' (-1.5) *is* part of a larger static expression, so the rule > in 4.9(38) doesn't apply. But I'm not sure just what does apply---is > the value of FpB'(-1.5) still assumed to be -1.5 (so that the type > conversion to FpA still results in -1.5), or should the type > conversion take place (which could result in -1.0 if truncation is > used for both type conversions), or is the result unspecified by the > language? The following statement is made in the annotated RM (4.9(38.d/2)): {AI95-00100-01} Note that the only machine numbers values of a fixed point type are the multiples of the small, so a static conversion to a fixed-point type, or division by an integer, must do truncation to a multiple of small. It is not correct for the implementation to do all static calculations in infinite precision. To me this makes it clear that conversions to a fixed point type within a larger static expression have to convert the value to a multiple of the small. What surprises me is that it says "truncation" in contrast to 4.9(38) itself. -- Dirk