Re: Real Time IO routines



On Fri, 26 Oct 2007 13:00:13 -0700, andrew wrote:

On Oct 26, 1:36 pm, Ludovic Brenta <ludo...@xxxxxxxxxxxxxxxxxx> 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. Kazakov
http://www.dmitry-kazakov.de
.



Relevant Pages

  • Re: A question about "kind"?
    ... present target platform. ... Maybe not so rare that one knows the precision requirement needed ... in longer precision than that single precision. ... no deficiencies and the other way is to make it so complicated ...
    (comp.lang.fortran)
  • Re: response time
    ... >> precision being as high as the platform on which you're running will ... > Also note that Windows' time, in particular, has a precision of only ... but based on a relatively mundane thing: ... This clock was divided by 3 to produce the 4.77MHz clock for the ...
    (comp.lang.python)
  • Re: getting current timestamp in micro secs
    ... I want to find the current time stamp in micro sec precision. ... For the portable C language as defined by the C standard the answer is that it is not possible. ... If you want an answer that is not platform specific then you are out of luck since there isn't one. ... If you want an answer for Unix like systems then ask the question in comp.unix.programmer where they deal with all the extensions to C provided by Unix including the ones you need. ...
    (comp.lang.c)
  • Re: I am trying read a file with mpi_file_read
    ... The other thing which might be a problem is precision... ... What platform are you on? ... drift wave turbulence: http://www.rzg.mpg.de/~bds/ ... Prev by Date: ...
    (comp.parallel.mpi)
  • Re: getting current timestamp in micro secs
    ... I want to find the current time stamp in micro sec precision. ... Then you'll have to ask in a group dedicated to your platform, ...
    (comp.lang.c)