[yunqa.de] Re: Rounding of REAL and DISQLite3Api.DateTimeToJulianDate

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Wed, 25 Feb 2009 14:41:44 +0100

Edwin Yip wrote:

>It seems that rounding with precision 4 is not OK, for example SQL:
>SELECT datetime(2454888.2673), datetime(2454888.2674), datetime(2454888.2675)
>
>returns:
>18:24:54, 18:25:03 and 18:25:12 respectively in the time part, so precision 4 
>is not precise enough. what do you think caused this on the data in my 
>database? thank you.

The rounding precision depends on the precision you need. Sine you are dealing 
with datetime values here, hours, minutes, and seconds are represented as 
fractions. The number of seconds per day is 24 * 60 * 60 = 86400. So the 
minimum fraction for one second is 1.15740740740741e-5 = 0.0000115740740740741. 
This should explain why your Julian day value needs at least 5 digits to 
represent a time value to represent down to the second representation.

Example:

  SELECT
    strftime ('%S', 0.00001), 
    strftime ('%S', 0.00002),
    strftime ('%S', 0.00003),
    strftime ('%S', 0.00004)

Ralf 

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: