From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ca038f7e5f1aa1b9 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Arithmetic with durations Date: 1997/09/10 Message-ID: #1/1 X-Deja-AN: 271354104 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <873869111.49snx@jvdsys.nextjk.stuyts.nl> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-09-10T00:00:00+00:00 List-Id: 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