l_fp, time, calendar

Fred Wright fw at fwright.net
Sat Mar 25 22:13:24 UTC 2017


On Sat, 25 Mar 2017, Hal Murray wrote:

> Quick summary:  I think the old code tried to use l_fp format times all over
> the place.  That may have made sense in the pre POSIX days, but I think we
> should switch to time_t and timespec everywhere except in the packet.

Oh, please, not more timespec crap.  The timeval and timespec stuff was
just a workaround for the lack of 64-bit integer support in C.  Once you
can count on 64-bit integers, then integer nanoseconds is a much cleaner
format.  A signed 64-bit nanosecond count has a range of +/- 292 years.

> We should probably invent something like a timespec so we keep all the low
> order bits.  If I'm counting right, there are 53 bits of fraction in a
> double.  With 32 for seconds, that leaves only 21 for fraction.  That's 1/2
> microsecond.

Doubles are perfectly adequate for *intervals*, but not absolute times.
You don't lose nanosecond resolution until the interval exceeds 52 days.

Fred Wright


More information about the devel mailing list