Re: Real Time IO routines
- From: Ludovic Brenta <ludovic@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 26 Oct 2007 22:29:58 +0200
andrew writes:
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?
--
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.
.
- Follow-Ups:
- Re: Real Time IO routines
- From: Dmitry A. Kazakov
- Re: Real Time IO routines
- References:
- Real Time IO routines
- From: andrew
- Re: Real Time IO routines
- From: Anh Vo
- Re: Real Time IO routines
- From: andrew
- Re: Real Time IO routines
- From: Anh Vo
- Re: Real Time IO routines
- From: andrew
- Re: Real Time IO routines
- From: Ludovic Brenta
- Re: Real Time IO routines
- From: andrew
- Real Time IO routines
- Prev by Date: Re: Real Time IO routines
- Next by Date: Re: Real Time IO routines
- Previous by thread: Re: Real Time IO routines
- Next by thread: Re: Real Time IO routines
- Index(es):