On 22 April 2016 at 14:54, Stephan Beal <sgbeal at googlemail.com> wrote:
> On Fri, Apr 22, 2016 at 8:43 AM, Clemens Ladisch <clemens at ladisch.de>
> wrote:
> > sqlite> select julianday('2000-01-01 00:00:00');
> > ...> select julianday('2000-01-01 00:00:01');
> > ...> select julianday('2000-01-01 00:00:02');
> > 2451544.5
> > 2451544.50001157
> > 2451544.50002315
>
> but i beg to differ that that works in 100% of cases.
>
Lets see, for a 64-bit float we have 53 bits of significand. The number
before the decimal point (2,451,544) accounts for 22 bits, so we have 31
left for the fraction. ie. the precision we can represent is on the order
of 2^-31 (around 4.6566e-10). To represent one second in a julian day, we
need precision of 1 / 86,400 (around 1.1574e-5).
So we have plenty of precision available, definitely enough to support
milliseconds.
On julianday 4,194,304 (6771-07-07 12:00:00) we'll lose one bit of
precision, but there's still enough for milliseconds. It's at least a
million years before the fraction is imprecise enough to cause a *second*
of ambiguity. Pretty sure your conversion issues are not the fault of the
julian day format :)
-Rowan