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=0.2 required=5.0 tests=BAYES_00,FROM_ADDR_WS, INVALID_MSGID,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7a434e753b9dd044 X-Google-Attributes: gid103376,public From: Wayne Magor Subject: Re: Time_Span divide question Date: 1997/05/19 Message-ID: <5lq6r1$kq2@castor.cca.rockwell.com>#1/1 X-Deja-AN: 243305902 Distribution: world Sender: wemagor@sym1.cca.rockwell.com (Wayne Magor) References: <5lg555$rba3@castor.cca.rockwell.com> Organization: Rockwell Collins - Avionics Reply-To: No@Junk.Mail Newsgroups: comp.lang.ada Date: 1997-05-19T00:00:00+00:00 List-Id: Tucker Taft writes: > >: Should these print the same value? > >: D1 := 0.495; >: D2 := 0.500; >: Put_Line ("Duration divide result: " & Integer'Image(Integer(D1/D2))); > >The conversion form fixed point to integer requires rounding, >so this will certainly give 1. I agree. Someone told me that GNAT generates a zero. Must be a bug in GNAT (I think it was the NT one). >: I suspect that is correct, but why is there no divide returning a Time_Span? > >There is. But it represents the result of dividing a time span by >an integer. Dividing a time span by a time span is clearly producing >a unitless, non-time value. (E.g. seconds/seconds = unitless). A Duration can be divided by a Duration. Sometimes you want a unitless result. I want to divide a time by a period to get the number of cycles. >: What about "rem"? > >This can be computed by multiplying the quotient by the divisor and >subtracting it from the dividend. In retrospect, it would probably have >made sense to include it and "mod" just for completeness, but probably because >we were comparing with the operators on Duration, there was no >dicussion of "rem" or "mod." They should be added to the next version of Ada.Real_Time, don't you think? This is very minor, but would be nice for completeness.