On Dec 27, 2006, at 14:32, Poul-Henning Kamp wrote:
>> It's impossible to accurately represent a millisecond using binary
>> fractions. That would be unacceptable for most sub-second use.
>
> Reality check: with a 32bit fraction, the error would be 69 ps.
...which accumulates in arithmetic and causes equality comparisons to
fail. This should hold:
1000 * 1ms == 1s
It won't if you use a binary fraction.
>> A better idea might have been to use Haskell's "Rational" type for
>> the seconds offset, which is stored as two integers (for numerator
>> and denominator). Instead I used a fixed-point type (internally just
>> an integer from 0 to 86400999999999999). It does not separate
>> "integer" and "decimal" part.
>
> Yes, let us make it as expensive as possible to operate on timestamps,
> so that everybody will have to invent their own faster type.
>
> NOT!
I'm not seeing the problem here: you can represent an integer in the
range 0 to 86400999999999999 with a 64-bit type. There's nothing
faster than integer arithmetic.
--
Ashley Yakeley
Received on Wed Dec 27 2006 - 14:55:18 PST