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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,75c440b4b7ed5f91 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Real Time IO routines Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1193410739.367181.96050@50g2000hsm.googlegroups.com> <1193416987.425545.80810@v29g2000prd.googlegroups.com> <1193417619.216687.95600@v3g2000hsg.googlegroups.com> <1193418278.033289.106280@y27g2000pre.googlegroups.com> <1193419270.872928.86840@57g2000hsv.googlegroups.com> <873avxg1uv.fsf@ludovic-brenta.org> <1193428813.533744.163870@o80g2000hse.googlegroups.com> Date: Fri, 26 Oct 2007 22:33:46 +0200 Message-ID: <16o6lua8t1589.7jh7lsdh2d8i$.dlg@40tude.net> NNTP-Posting-Date: 26 Oct 2007 22:33:46 CEST NNTP-Posting-Host: 81979e1a.newsspool3.arcor-online.net X-Trace: DXC=O`E:F8\aWf_Fm0Y?OE@2^XMcF=Q^Z^V3X4Fo<]lROoRQ4nDHegD_]RUP\6UoC7ZkUYDNcfSJ;bb[UIRnRBaCdl On Fri, 26 Oct 2007 13:00:13 -0700, andrew wrote: > On Oct 26, 1:36 pm, Ludovic Brenta 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