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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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!news1.google.com!news.glorb.com!border-1.ams.xsnews.nl!feed.xsnews.nl!border-2.ams.xsnews.nl!68.142.88.77.MISMATCH!hwmnpeer03.ams!news.highwinds-media.com!xlned.com!feeder1.xlned.com!feeder2.cambrium.nl!feed.tweaknews.nl!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Real Time IO routines 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:29:58 +0200 Message-ID: <87prz1ei0p.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:ODq2GbyyYhjLS3kMbQ8jCG55g+Q= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tele2 X-Trace: DXC=lQKmN]EG2oXG>D9`j;4j^X6`Y6aWje^YZYgU<_R06mN[ECVRUO7T7?UMN?VOIR Xref: g2news2.google.com comp.lang.ada:2594 Date: 2007-10-26T22:29:58+02:00 List-Id: andrew writes: > 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? >> >> -- >> Ludovic Brenta. > > To Ludovic: Ahh, so if I had to define a universal_real I could > output it using something like integer'image(it)? No, because Integer is not a floating-point type. You would use Float'Image instead. In light of what follows, I forgot to mention that universal_real also converts to any fixed-point type implicitly. > 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. > > So if a duration is represented as the stored INTEGER ... then I could > maybe use integer'image(duration), maybe? No; Time and Time_Span are fixed-point types, not integer types. You should do: Nanosecond : constant := 1.0E-9; -- there's your universal_real :) type My_Fixed_Time is delta Nanosecond range 0.0 .. (2 ** 64 - 1) * Nanosecond; for My_Fixed_Time'Size use 64; function To_My_Fixed_Time is new Ada.Unchecked_Conversion (Source => Time; Target => My_Fixed_Time); T : Time; Image : constant String := My_Fixed_Time'Image (To_My_Fixed_Time (T)); (I just made that up; didn't try to compile it so caveat emptor). > what does this mean: type DURATION is delta implementation_defined > range implementation_defined;? > Is delta? what's delta? A fixed-point type. See ARM 3.5.9. -- Ludovic Brenta.