From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Fixed point constants issue
Date: Mon, 13 Sep 2010 13:35:46 -0700
Date: 2010-09-13T13:35:46-07:00 [thread overview]
Message-ID: <i6m1v2$e5b$1@adenine.netfront.net> (raw)
In-Reply-To: <8f7b0nF6hfU1@mid.individual.net>
On 09/13/2010 12:05 PM, Niklas Holsti wrote:
>
> The declaration of TEN_FEET_1 is a named-number declaration, so the
> expression is evaluated using the "root" multiplication operator "*"
> (Left : root_integer; Right : root_real) return root_real, which is done
> at compile-time and exactly (with unlimited precision).
Right.
> > I would expect the compiler to evaluate the expression
> > "HEIGHT * FEET_PER_METER" [for TEN_FEET_2] _before_
> > converting it to the appropriate fixed point type.
>
> The declaration of TEN_FEET_2 is an object declaration with type
> Altitude, therefore the right-hand-side expression is expected to be of
> type Altitude and so the "*" will be resolved to the Altitude
> multiplication operator "*" (Left, Right : Altitude) return Altitude,
> with result zero.
More likely,
function "*" (Left : in Integer; Right : in Altitude) return Altitude;
[ARM 4.5.5(14)]. Feet_Per_Meter will be converted to Altitude before calling
this function, resulting in a value of 0.0.
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.
If the target compiler gives 3.0 as the value, then perhaps it is an Ada-83
compiler.
There is a further wrinkle with the Ada 95 (and current Ada) rule. If "*" has
not been overridden, this is a static expression and is evaluated at compile
time. If "*" has been overridden, then this is not a static expression and it
will be evaluated at run time.
--
Jeff Carter
"Mr. President, we must not allow a mine-shaft gap!"
Dr. Strangelove
33
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
next prev parent reply other threads:[~2010-09-13 20:35 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-13 17:27 Fixed point constants issue Vinzent Hoefler
2010-09-13 18:04 ` Dmitry A. Kazakov
2010-09-13 18:25 ` Vinzent Hoefler
2010-09-13 19:05 ` Niklas Holsti
2010-09-13 20:35 ` Vinzent Hoefler
2010-09-13 20:35 ` Jeffrey Carter [this message]
2010-09-13 21:06 ` Vinzent Hoefler
2010-09-14 5:39 ` Niklas Holsti
2010-09-24 14:43 ` Markus Schöpflin
2010-09-24 20:05 ` Vinzent Hoefler
2010-09-24 21:38 ` Jeffrey Carter
2010-09-24 22:42 ` Vinzent Hoefler
2010-09-25 0:16 ` Jeffrey Carter
2010-09-27 10:33 ` Markus Schöpflin
2010-09-27 18:57 ` Jeffrey Carter
2010-09-28 8:16 ` Markus Schöpflin
2010-09-28 17:28 ` Jeffrey Carter
2010-10-05 6:27 ` Randy Brukardt
2010-10-05 18:40 ` Jeffrey Carter
2010-09-27 17:58 ` Adam Beneschan
2010-09-13 20:32 ` Dmitry A. Kazakov
2010-09-13 21:08 ` Vinzent Hoefler
2010-09-14 6:54 ` J-P. Rosen
2010-09-14 18:28 ` Vinzent Hoefler
2010-09-14 7:47 ` Dmitry A. Kazakov
2010-09-14 17:42 ` Vinzent Hoefler
2010-09-15 8:35 ` Dmitry A. Kazakov
2010-09-15 17:24 ` Vinzent Hoefler
2010-09-15 20:11 ` Dmitry A. Kazakov
2010-09-14 19:44 ` Keith Thompson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox