From: andrew <andrew.carroll@okstate.edu>
Subject: Re: Real Time IO routines
Date: Fri, 26 Oct 2007 14:14:27 -0700
Date: 2007-10-26T14:14:27-07:00 [thread overview]
Message-ID: <1193433267.671789.134690@50g2000hsm.googlegroups.com> (raw)
In-Reply-To: <16o6lua8t1589.7jh7lsdh2d8i$.dlg@40tude.net>
On Oct 26, 3:33 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Fri, 26 Oct 2007 13:00:13 -0700, andrew wrote:
> > On Oct 26, 1:36 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> >> andrew writes:
> >>> Time_Unit is defined as a constant := 10#1.0#E-9, is Time_Unit then
> >>> a "real literal"? How can I convert a "real literal" to a scalar
> >>> type (maybe that's a contradiction?)?
>
> >> Real literals are of the type universal_real which (a) is scalar and
> >> (b) converts implicitly to any other floating-point type. Does that
> >> answer your question?
>
> > To Ludovic: Ahh, so if I had to define a universal_real I could
> > output it using something like integer'image(it)?
>
> > To AV: I don't really know why it's necessary yet; sometimes my
> > subconcious mind works faster than my concious mind and I just have to
> > go with it. I can say though that:
>
> > -- Time and Time_Span are represented in 64-bit Duration value in
> > -- in nanoseconds. For example, 1 second and 1 nanosecond is
> > -- represented as the stored integer 1_000_000_001.
>
> You never know, that depends on the underlying hardware and OS. Even under
> the same hardware/OS there exist multiple time sources with their own
> precision and accuracy.
>
> > So if a duration is represented as the stored INTEGER ... then I could
> > maybe use integer'image(duration), maybe?
>
> > what does this mean: type DURATION is delta implementation_defined
> > range implementation_defined;?
>
> It varies from platform to platform
>
> > Is delta? what's delta?
>
> Precision of a fixed-point type. See ARM 3.5.9.
>
> with Ada.Real_Time; use Ada.Real_Time;
> with Ada.Text_IO; use Ada.Text_IO;
>
> procedure Test is
> Start : Time := Clock;
> Period : Duration;
> type Seconds is delta 0.000_001 range -1.0E10 .. 1.0E10;
> -- Microsecond precision type
> begin
> delay 0.5;
> Period := To_Duration (Clock - Start);
> Put_Line ("Duration delta on this computer = " & Float'Image
> (Duration'Delta));
> Put_Line (Duration'Image (Period) & "s");
> Put_Line (Integer'Image (Integer (Period * 1000.0)) & "ms");
> -- Be careful here, as it might overflow first in the multiplication
> -- and then in conversion to integer
> Put_Line (Float'Image (Float (Period)) & "s");
> Put_Line (Seconds'Image (Seconds (Period)) & "s");
> end Test;
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de- Hide quoted text -
>
> - Show quoted text -
This is all great information; thank you all those that posted.
Something seems to be wrong though. In my program I am basiclly
doing:
start := clock;
--I run my algorithm here
finish := clock;
ada.Text_IO.put_line("time = " & duration'image(to_duration(finish -
start)));
the output is always time = 0.000000000. I know it had to take some
time because it takes about 10 seconds for the program to reach that
point in the code. Overflow maybe?
next prev parent reply other threads:[~2007-10-26 21:14 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-26 14:58 Real Time IO routines andrew
2007-10-26 16:43 ` Anh Vo
2007-10-26 16:53 ` andrew
2007-10-26 17:04 ` Anh Vo
2007-10-26 17:21 ` andrew
2007-10-26 18:31 ` Anh Vo
2007-10-26 18:36 ` Ludovic Brenta
2007-10-26 20:00 ` andrew
2007-10-26 20:29 ` Ludovic Brenta
2007-10-26 20:46 ` Dmitry A. Kazakov
2007-10-26 20:33 ` Dmitry A. Kazakov
2007-10-26 21:14 ` andrew [this message]
2007-10-26 21:54 ` Anh Vo
2007-10-26 22:34 ` Adam Beneschan
2007-10-27 1:58 ` tmoran
2007-10-27 12:40 ` John McCormick
2007-10-27 20:12 ` andrew
2007-10-26 17:12 ` Ed Falis
2007-10-27 8:56 ` anon
2007-10-27 10:18 ` Dmitry A. Kazakov
2007-10-27 20:15 ` anon
2007-10-27 20:49 ` Dmitry A. Kazakov
2007-10-27 21:51 ` Simon Wright
2007-10-28 11:35 ` Ludovic Brenta
2007-10-30 14:37 ` Simon Clubley
2007-10-30 13:47 ` Ludovic Brenta
2007-10-30 14:46 ` Jean-Pierre Rosen
2007-10-31 14:38 ` Ada coding standards, was: " Simon Clubley
2007-10-31 18:02 ` anon
2007-10-31 19:23 ` Georg Bauhaus
2007-10-31 20:40 ` John W. Kennedy
2007-11-01 11:27 ` Stephen Leake
2007-11-01 20:38 ` anon
2007-10-29 19:28 ` Real Time IO routines -- answering Simon Wright part 1 anon
2007-10-29 21:24 ` Georg Bauhaus
2007-10-29 21:31 ` Georg Bauhaus
2007-10-29 22:01 ` Dmitry A. Kazakov
2007-10-29 22:38 ` Keith Thompson
2007-10-30 0:58 ` tmoran
2007-10-30 16:35 ` Real Time IO routines answering Simon Wright part 2 anon
2007-10-30 21:50 ` Simon Wright
2007-10-31 15:35 ` Adam Beneschan
2007-10-31 20:08 ` anon
2007-10-31 21:08 ` Georg Bauhaus
2007-10-31 21:42 ` Markus E L
2007-11-01 1:00 ` Adam Beneschan
2007-10-28 1:15 ` Real Time IO routines Jeffrey Creem
2007-10-29 16:18 ` Adam Beneschan
2007-10-29 16:40 ` Robert A Duff
2007-10-29 17:26 ` Adam Beneschan
2007-10-29 22:34 ` Keith Thompson
2007-10-29 17:25 ` Jean-Pierre Rosen
2007-11-15 4:27 ` Randy Brukardt
2007-11-15 4:27 ` Randy Brukardt
2007-10-29 18:53 ` andrew
2007-10-29 22:35 ` Keith Thompson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox