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,31d67020d4b04d5b X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Simple Real_Time.Time_Span question Date: 1998/10/16 Message-ID: #1/1 X-Deja-AN: 401580108 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <705n7o$ro2$1@nnrp1.dejanews.com> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1998-10-16T00:00:00+00:00 List-Id: dennison@telepath.com wrote: : ... : Even though this code has to be portable, I probably would have considered : cheating and using Duration if I could have found any documentation from my : compiler vendor on how it is implemented. Unfortunately, there seem to be : *no* documentation requirements on Duration (unlike all *other* predefined : types), so my vendor didn't bother to document it. Lucky me. There should be an "annex M" which contains such information. But even without it, it is pretty trivial to found out information about predefined types. E.g.: with Ada.Text_IO; use Ada.Text_IO; procedure Tell_Me_About_Duration is begin Put_Line("Duration'Size = " & Integer'Image(Duration'Size)); Put_Line("Duration'Small = " & Float'Image(Duration'Small)); Put_Line("Duration'First = " & Duration'Image(Duration'First)); Put_Line("Duration'Last = " & Duration'Image(Duration'Last)); end; On one of our compilers, this produces the following: Duration'Size = 32 Duration'Small = 6.10352E-05 Duration'First = -131072.0000 Duration'Last = 131071.9999 I suspect a number of Ada 95 compilers will produce the same result. In any case, I sympathize with your goal. The simplest solution I have heard suggested is the following: function To_Float(TS : Time_Span) return Float is SC : Seconds_Count; Frac : Time_Span; begin Split(Time_Of(0, TS), SC, Frac); return Float(SC) + Time_Unit * Float(Frac/Time_Span_Unit); end To_Float; : -- : T.E.D. -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA An AverStar Company