emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inverse of float-time?


From: Ulrich Mueller
Subject: Re: inverse of float-time?
Date: Thu, 12 Sep 2013 18:30:19 +0200

>>>>> On Wed, 11 Sep 2013, Paul Eggert wrote:

> Sam Steingold wrote:
>> what I want is for float time to be transparently accepted by
>> all functions which accept list time.

> On second thought I'm not sure I want to encourage that.
> Floating-point loses information, due to rounding, and this can
> cause glitches that can make floating-point more trouble than it's
> worth.

> For example, if gettimeofday reports 1378930161.099999786 seconds
> after 1970, then current-time returns the exact representation
> (21040 52721 99999 786000) but float-time rounds this to
> 1378930161.1.  Sure, it's a small error, but the fact that
> it's nonzero can cause problems.

Python also uses floating point numbers for time, and the error is
large enough to lose three decimal digits for filesystem timestamps
which have nanosecond precision. This is really awkward when one needs
to compare timestamps for equality.

(It's not surprising, because the IEEE 754 double format provides only
52 bits for the mantissa, whereas 31 + 30 = 61 bits are (currently!)
needed to represent seconds and nanoseconds.)

Ulrich



reply via email to

[Prev in Thread] Current Thread [Next in Thread]