From: Dirk Herrmann <fight_spam@invalid.invalid>
Subject: Re: conversions between fixed-point types
Date: Sat, 26 Sep 2009 16:31:57 +0200
Date: 2009-09-26T16:31:57+02:00 [thread overview]
Message-ID: <h9l8kt$qa2$1@news.albasani.net> (raw)
In-Reply-To: <c8af7daf-9f00-4dbb-ad0d-9ca65e0a83d6@f18g2000prf.googlegroups.com>
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
next prev parent reply other threads:[~2009-09-26 14:31 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-18 21:35 conversions between fixed-point types Dirk Herrmann
2009-09-18 22:42 ` Adam Beneschan
2009-09-19 12:41 ` Dirk Herrmann
2009-09-19 14:48 ` John B. Matthews
2009-09-20 8:15 ` Dirk Herrmann
2009-09-20 14:22 ` Robert A Duff
2009-09-20 18:55 ` Dirk Herrmann
2009-09-20 20:34 ` Simon Clubley
2009-09-23 20:46 ` Dirk Herrmann
2009-09-27 17:15 ` Simon Clubley
2009-09-27 19:22 ` sjw
2009-09-28 20:18 ` Dirk Herrmann
2009-09-28 18:37 ` Robert A Duff
2009-09-28 20:50 ` Dirk Herrmann
2009-09-20 15:18 ` John B. Matthews
2009-09-20 19:13 ` Dirk Herrmann
2009-09-20 20:09 ` tmoran
2009-09-21 17:24 ` Jeffrey R. Carter
2009-09-23 20:57 ` Dirk Herrmann
2009-09-23 22:28 ` Jeffrey R. Carter
2009-09-24 1:05 ` Adam Beneschan
2009-09-24 3:57 ` Jeffrey R. Carter
2009-09-25 8:47 ` Stuart
2009-09-25 20:41 ` sjw
2009-09-25 21:58 ` Jeffrey R. Carter
2009-09-28 13:40 ` Stuart
2009-09-26 14:43 ` Dirk Herrmann
2009-09-28 15:15 ` Adam Beneschan
2009-09-26 14:31 ` Dirk Herrmann [this message]
2009-09-19 18:38 ` tmoran
2009-09-20 8:22 ` sjw
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox