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.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,350a90791b49a5b1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-01 06:54:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!paloalto-snf1.gtei.net!news.gtei.net!enews.sgi.com!news-out.spamkiller.net!propagator-la!news-in-la.newsfeeds.com!news-in.superfeed.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <3BB78935.33B5C91A@ida.his.se> <5ee5b646.0109301518.2a49abc4@posting.google.com> Subject: Re: Time to float?? Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Mon, 01 Oct 2001 09:54:31 EDT Organization: http://www.newsranger.com Date: Mon, 01 Oct 2001 13:54:31 GMT Xref: archiver1.google.com comp.lang.ada:13574 Date: 2001-10-01T13:54:31+00:00 List-Id: In article <5ee5b646.0109301518.2a49abc4@posting.google.com>, Robert Dewar says... > >Michael Andersson wrote in message news:<3BB78935.33B5C91A@ida.his.se>... >> Could somebody please show me how to convert Ada.Real_time type Time to >> a float so that for example 1.5 seconds is represented as the real >> number 1.5. > >This is not a meaningful conversion. the type Time >represents a time, not a duration. That's true. But *two* of them can be used for that purpose. I often find myself doing this conversion in debugging code, so that I can make checkpoint outputs of the result at various places. There are two ways to do this; a thourough way and a quick-and-dirty way. Since I ususally do this for debugging purpose, I ususaly pick the latter. The way I have done this is to subtract Ada.Real_Time.Time_First from Ada.Real_Time.Clock. Then you can take the resulting Time_Span and pass it to Ada.Real_Time.To_Duration. The resulting duration (fixed point, not floating point), can be displayed by passing it to Duration'Image. If you really need to, you can always convert your duration to float with a simple numeric type conversion, but that's an unnessecary step. (Fixed-point is your friend). Of course you may loose some information somewhere along the way, particularly if the delta is greater than can fit in a Time_Span. If you want a really accurate display, you should use Split. You can then convert the Seconds_Count to float, then call To_Duration on the Time_Span, convert it to float, and add the two. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.