From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Arithmetic with durations
Date: 1997/09/10
Date: 1997-09-10T00:00:00+00:00 [thread overview]
Message-ID: <EGB0G3.1M.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 873869111.49snx@jvdsys.nextjk.stuyts.nl
Jerry van Dijk (jerry@jvdsys.nextjk.stuyts.nl) wrote:
: In article <34149060.2E21@home.com> lmcoon@home.com writes:
: >The line that calculates the amount of simulation
: >time to wait for each event won't compile. My
: >compiler (Thomson ObjectAda running in Windows 95)
: >produces the following diagnostic: "LRM:4.5.5(20)
: >The fixed-fixed multiplying operators shall not be
: >used in a context where the expected type for the
: >result is universal_fixed."
: ...
: Sim_Delay_Time := Real_Delay_Time * Total_Sim_Time / Total_Real_Time;
: If you looked up 4.5.5 you will have found that the rule used for
: the multiplication is given in 4.5.5 (19):
: function "*" (Left, Right : universal_fixed) return universal_fixed.
: However, line (20) then makes the exception that this will only work
: if the destination type is something other then universal_fixed, either
: im- or explicit.
: However, as the result of the multiplication will be used for a
: division also defined in 4.5.5 (19) the resulting type _is_
: implicitly an universal_fixed, so the multiplication is illegal.
: To fix the problem, simply make the return type explicit, like:
: ...
: Sim_Delay_Time := Duration (Real_Delay_Time * Total_Sim_Time)
: / Total_Real_Time;
: Now, perhaps one of our resident RM guru's can answer the really
: interesting question: why this exception ?
The fixed-fixed multiplying operators are defined to return
infinite precision. Of course, that is a bit inefficient to do
at run-time. Hence, you are required to coerce the result to
some particular finitely precise numeric type. Hence the
rule that you can't use the output of a fixed-fixed multiplying
operator as an input to another one, without first coercing it
to a particular, non-infinite-precision, numeric type.
: --
: -- Jerry van Dijk | Leiden, Holland
: -- Consultant | Team Ada
: -- Ordina Finance | jdijk@acm.org
--
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Burlington, MA USA
next prev parent reply other threads:[~1997-09-10 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-09-08 0:00 Arithmetic with durations Larry Coon
1997-09-09 0:00 ` Simon Wright
1997-09-10 0:00 ` Jerry van Dijk
1997-09-10 0:00 ` Tucker Taft [this message]
1997-09-11 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox