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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: How to round to the nearest fixed-point value? Date: Tue, 28 Jan 2014 17:43:39 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1390952620 5921 69.95.181.76 (28 Jan 2014 23:43:40 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 28 Jan 2014 23:43:40 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:18309 Date: 2014-01-28T17:43:39-06:00 List-Id: "Natasha Kerensikova" wrote in message news:slrnlea6aj.1lme.lithiumcat@sigil.instinctive.eu... > On 2014-01-24, Randy Brukardt wrote: >> "Natasha Kerensikova" wrote in message >>> In case anyone is interested, the following rewrite works around the >>> problem: >>> >>> function Convert (Value : High) return Low is >>> begin >>> return Low'Round (Value * 1.0); >>> end Convert; >> >> I believe the above should be illegal - but in any case, it's not clear >> from >> the RM what this means. >> >> The only multiply operations available for fixed point types either have >> one >> operand that is an integer (not the case above), or produce a >> Universal_Fixed result. 4.5.5(19.1/2) requires that the result be used in >> a >> context where the result type is identified, and specifically disallows >> the >> result from being Universal_Fixed. >> >> The type of the operand of 'Round is Universal_Real. This appears to meet >> the letter of the rule, but not the intent (which is that the expected >> type >> determine the scaling and respresentation for the result). > > Could it be somehow be "made legal" by G.2.3(4), merging "*" and > Low'Round into a single operation? (sounds a bit weird though, that > would mean an optional annex affecting legality) Tucker says that it's legal, and that G.2.3(4) defines what it means. I'm dubious about that last part, but mainly for wording reasons (the wording ought to say that 'Round *is* a conversion for the purposes of the rules in G.2.3; "implying" a conversion is vague at best). This appears to be a "hack" in the language that I wasn't aware of; I agree with you that it's weird that it's only defined in an optional annex -- but that's true for much of the semantics of float and fixed numbers so it follows the existing pattern. So probably you ought to ignore my previous notes on this topic, sorry about that. Randy.