comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: How to convert an Fixed_Point to to an Integer ?
Date: 1996/12/25
Date: 1996-12-25T00:00:00+00:00	[thread overview]
Message-ID: <dewar.851521881@merv> (raw)
In-Reply-To: 01bbf24c$a8db4800$b72d5c8b@jerryware


iJerry said (wrt my solution of the epoch problem)

"Yep, but I will await your reaction to Norman's comment first."

Well your original solution was even more GNAT specific :-)

The question is whether or not there are Ada 95 compilers (other than
GNAT) that actually have a very limited range for Duration. It is quite
possible that the answer is yes. In GNAT, 64-bit integer and 64-bit
fixed-point arithmetic are always available on all targets, and Duration
is a 64-bit fixed-point value.

However, surprisingly, many Ada 83 technologies did not support integer
values longer than 32 bits, so it would not surprise me if there are
Ada 95 compilers around with 32-bit Duration (it is *just* possible to
squeeze Duration in to 32 bits -- by design). I feel that taking advantage
of this permission to provide a very restricted duration is unfortunate,
but if you want to write completely Rm-portable code, then Norman is
right, you should take this into account.

The way to do this is to write a loop using Time_Of that goes forward one
year at a time, accumulating seconds, starting with 1970, till you get to
the year you want. Of course you could make this a memo function so that
once it knew the number of seconds to the start of a given year, it would
not compute it again.

Note that if you use Integer as the result, you are also creating another
source of potential portability problems. In GNAT, Integer is always at
least 32 bits, at least on all currnt targets (it is actually the sam
as the C int in length), but there may be Ada 95 compilers with smaller
Integer types, so really you should define an appropraite range type as
the result of this seconds-from-the-Unix-epoch call.

Better would be to make your program independent of this curious Unix-based
notion of the Epoch all together.

This being said, using the C routine is quite appropriate in this case anyway,
since obviously you are doing something rather Unix specific ....





  reply	other threads:[~1996-12-25  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-22  0:00 How to convert an Fixed_Point to to an Integer ? Jerry van Dijk
1996-12-23  0:00 ` Eric Miller
1996-12-23  0:00 ` Jerry van Dijk
1996-12-23  0:00 ` Larry Kilgallen
1996-12-23  0:00   ` Robert Dewar
1996-12-24  0:00     ` Jerry van Dijk
1996-12-24  0:00       ` Robert Dewar
1996-12-24  0:00         ` Norman H. Cohen
1996-12-24  0:00           ` Robert Dewar
1996-12-26  0:00             ` Keith Thompson
1996-12-26  0:00               ` Robert Dewar
1996-12-25  0:00         ` Jerry van Dijk
1996-12-25  0:00           ` Robert Dewar [this message]
1996-12-26  0:00             ` Norman H. Cohen
1996-12-27  0:00               ` Jerry van Dijk
1996-12-27  0:00                 ` Leap seconds in Unix time (was: Re: How to convert an Fixed_Point to to an Integer ?) Norman H. Cohen
1996-12-30  0:00               ` How to convert an Fixed_Point to to an Integer ? Mike Young
1996-12-30  0:00                 ` 2000 is a leap year (was: How to convert an Fixed_Point to to an Inte) Larry Kilgallen
1996-12-30  0:00                 ` How to convert an Fixed_Point to to an Integer ? Michael F Brenner
1996-12-31  0:00                 ` Keith Thompson
1997-01-02  0:00             ` 2000 is a leap year (was: How to convert an Fixed_Point to to an Inte) Mike Paley
1996-12-30  0:00 ` How to convert an Fixed_Point to to an Integer ? Steve Jones - JON
1996-12-30  0:00   ` Jacques Rouillard
1996-12-30  0:00 ` Steve Jones - JON
1996-12-30  0:00 ` Dave Barnes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox