From: "Markus Schöpflin" <no@spam.spam>
Subject: Re: Fixed point constants issue
Date: Fri, 24 Sep 2010 16:43:29 +0200
Date: 2010-09-24T16:43:29+02:00 [thread overview]
Message-ID: <i7idee$8ag$1@speranza.aioe.org> (raw)
In-Reply-To: i6m1v2$e5b$1@adenine.netfront.net
Forgive me for resurrecting an old thread, but when trying to understand
the issue, I came up with more questions...
Am 13.09.2010 22:35, schrieb Jeffrey Carter:
> 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.
Are you sure about that? Because I compiled and ran the following program
with an Ada 83 compiler (DEC Ada) and I got a different result. Note that I
modified the delta to 0.5 to avoid any issues resulting from delta /= small.
---%<---
with TEXT_IO; use TEXT_IO;
procedure FIXED_POINT
is
type ALTITUDE is delta 0.5 range 0.0 .. 50_000.0;
package ALTITUDE_IO is new FIXED_IO (ALTITUDE);
FEET_PER_METER : constant := 0.3048;
HEIGHT : constant := 10; -- Feet
TEN_FEET_1 : constant := HEIGHT * FEET_PER_METER;
TEN_FEET_2 : constant ALTITUDE := HEIGHT * FEET_PER_METER;
begin
ALTITUDE_IO.PUT (TEN_FEET_1); NEW_LINE; -- gives 3.0
ALTITUDE_IO.PUT (TEN_FEET_2); NEW_LINE; -- gives 5.0 (*)
end FIXED_POINT;
--->%---
(*) This certainly looks like FEET_PER_METER is converted to ALTITUDE
before doing the multiplication.
Another question regarding the implicit conversion from universal_real to
ALTITUDE: Does ARM83-3.5.6 apply here? And what does this mean: "If the
universal_real value is a safe number, the implicit conversion delivers the
corresponding value; if it belongs to the range of safe numbers but is not
a safe number, then the converted value can be any value within the range
defined by the safe numbers next above and below the universal_real value."
Is the compiler free to convert FEET_PER_METER to either 0.0 or 0.5?
Regards,
Markus
next prev parent reply other threads:[~2010-09-24 14:43 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
2010-09-13 21:06 ` Vinzent Hoefler
2010-09-14 5:39 ` Niklas Holsti
2010-09-24 14:43 ` Markus Schöpflin [this message]
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