Scott Baker uttered:

Christian Smith wrote:
If you use the julianday representation, the integer component is the
number of days since "noon in Greenwich on November 24, 4714 B.C", with
the fractional part being the fraction of that day. Hence, the
resolution is determined by the fractional component of the real number.
Now, in the UK, I get the following:
sqlite> select julianday('now');
2454295.1407767

The integer component consumes probably 21 bits of the available 52 bits
mantissa of an IEEE-754 64-bit real. That leaves 31 bits for the
fractions of a day, giving a resolution of 1/24855 of a second:
2^31/(60*60*24) = 24855.134814814814814814814814815

Plenty enough for milli-second resolution.

Probably not very good for embedded applications if an FPU is not
available.

I'm a little confused by the math... help me work this out.

sqlite> SELECT julianday('now');
2454295.20404931

That gives me days since the Julian epoch. If I multiply by 86400 I
should get seconds since the Julian epoch.

sqlite> SELECT julianday('now') * 86400;
212051105903.613

That leaves me three decimal points of precision for seconds. So
that's thousandths of a second? Where do you get 24000ths of a second?


The floating point representation used by SQLite maps to the IEEE 754 64-bit representation, which has 1 bit for sign, 11 bits for for the exponent, leaving 52 bits (effectively 53 bits including the implied leading 1 binary digit) for the precision.

Given that, the 2454295.20404931 uses 21 bits for the integral part of the number (before the floating point) including the implied initial 1 digit. That leaves 52-21 bits of precision, or 31 bits for the fraction of a day.

So, you have 1/2^31 days resolution, or 86400/2^31 seconds resolution. That is 1/24855.134814814814814814814814815 second resolution.

Christian


--
    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
     X                           - AGAINST MS ATTACHMENTS
    / \

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to