comp.lang.ada
 help / color / mirror / Atom feed
From: stt@houdini.camb.inmet.com (Tucker Taft)
Subject: Re: Simple Real_Time.Time_Span question
Date: 1998/10/16
Date: 1998-10-16T00:00:00+00:00	[thread overview]
Message-ID: <F0wCFH.In.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 705n7o$ro2$1@nnrp1.dejanews.com

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




  reply	other threads:[~1998-10-16  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-13  0:00 Simple Real_Time.Time_Span question dennison
1998-10-13  0:00 ` David C. Hoos, Sr.
1998-10-13  0:00   ` dennison
1998-10-14  0:00     ` Robert I. Eachus
1998-10-14  0:00       ` Keith Thompson
1998-10-14  0:00       ` Jonathan Guthrie
1998-10-15  0:00         ` dennison
1998-10-16  0:00           ` Tucker Taft [this message]
1998-10-16  0:00             ` dennison
1998-10-16  0:00               ` dewar
1998-10-17  0:00           ` Niklas Holsti
1998-10-14  0:00     ` Niklas Holsti
1998-10-14  0:00       ` Niklas Holsti
1998-10-13  0:00 ` dennison
1998-10-13  0:00 ` Tucker Taft
1998-10-14  0:00 ` dewar
1998-10-14  0:00   ` dennison
1998-10-14  0:00     ` Matthew Heaney
1998-10-14  0:00     ` Robert I. Eachus
1998-10-15  0:00       ` dennison
1998-10-16  0:00         ` Robert I. Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox