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: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) Subject: Re: Arithmetic with durations Date: 1997/09/10 Message-ID: <873869111.49snx@jvdsys.nextjk.stuyts.nl>#1/1 X-Deja-AN: 271164423 Distribution: world References: <34149060.2E21@home.com> Organization: *JerryWare HQ*, Leiden, Holland Newsgroups: comp.lang.ada Date: 1997-09-10T00:00:00+00:00 List-Id: 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." Removing the fat, the problem becomes: procedure Main is Sim_Delay_Time : Duration; Real_Delay_Time: constant Duration := 25.0; Total_Sim_Time : constant Duration := 100.0; Total_Real_Time: constant Duration := 1000.0; begin Sim_Delay_Time := Real_Delay_Time * Total_Sim_Time / Total_Real_Time; end Main; 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: procedure Main is Sim_Delay_Time : Duration; Real_Delay_Time: constant Duration := 25.0; Total_Sim_Time : constant Duration := 100.0; Total_Real_Time: constant Duration := 1000.0; begin Sim_Delay_Time := Duration (Real_Delay_Time * Total_Sim_Time) / Total_Real_Time; end Main; Now, perhaps one of our resident RM guru's can answer the really interesting question: why this exception ? -- -- Jerry van Dijk | Leiden, Holland -- Consultant | Team Ada -- Ordina Finance | jdijk@acm.org