comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: How to round to the nearest fixed-point value?
Date: Tue, 28 Jan 2014 17:43:39 -0600
Date: 2014-01-28T17:43:39-06:00	[thread overview]
Message-ID: <lc9fbc$5p1$1@loke.gir.dk> (raw)
In-Reply-To: slrnlea6aj.1lme.lithiumcat@sigil.instinctive.eu

"Natasha Kerensikova" <lithiumcat@gmail.com> wrote in message 
news:slrnlea6aj.1lme.lithiumcat@sigil.instinctive.eu...
> On 2014-01-24, Randy Brukardt <randy@rrsoftware.com> wrote:
>> "Natasha Kerensikova" <lithiumcat@gmail.com> 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.


      reply	other threads:[~2014-01-28 23:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-22 16:48 How to round to the nearest fixed-point value? Natasha Kerensikova
2014-01-22 17:53 ` G.B.
2014-01-22 22:26   ` adambeneschan
2014-01-23  9:21     ` Georg Bauhaus
2014-01-22 22:45 ` adambeneschan
2014-01-23  5:29   ` J-P. Rosen
2014-01-23  7:00     ` Natasha Kerensikova
2014-01-23  9:42     ` Georg Bauhaus
2014-01-23  7:02   ` Natasha Kerensikova
2014-01-23 16:41     ` adambeneschan
2014-01-24  9:58 ` Natasha Kerensikova
2014-01-24 22:30   ` Randy Brukardt
2014-01-24 22:47     ` Randy Brukardt
2014-01-26 14:19     ` Natasha Kerensikova
2014-01-28 23:43       ` Randy Brukardt [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox