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

  • From: Edwin Yip <edwin.yip@xxxxxxxxxxxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Wed, 25 Feb 2009 21:04:33 +0800

HI Ralf,
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.

Best Regards,
Edwin Yip

Mind Mapping is as Effortless as Typing
http://www.InnovationGear.com


On Wed, Feb 25, 2009 at 8:50 PM, Edwin Yip <edwin.yip@xxxxxxxxxxxxxxxxxx>wrote:

> Thank you Ralf, using the ROUND function solves the problem, it seems that
> the max value for precession is 4, or the comparison will fail, I don't
> understand why, would you explain on this? thank you.
>
>
> Best Regards,
> Edwin Yip
>
> Mind Mapping is as Effortless as Typing
> http://www.InnovationGear.com
>
>
> On Wed, Feb 25, 2009 at 8:01 PM, Delphi Inspiration <delphi@xxxxxxxx>wrote:
>
>> Edwin Yip wrote:
>>
>> >The problem is that  the above select statement does not return any
>> records, I think this is because of the difference after rounding (calling
>> of DateTimeToJulianDate), but I HAVE use this datetime value to match the
>> records, it's of the the combined primary keys. Any suggestion to solve my
>> problem? Thank you.
>>
>> Precision is an inherited problem in floating point arithmetic. See
>>
>>  http://en.wikipedia.org/wiki/Floating_point
>>
>> Therefore the recommendation is not to use double / floating point types
>> for exact record matches. If you must do so, consider using ROUND(number,
>> precision) on both sides of the comparison to compensate for rounding errors
>> or compare against a range of values to satisfy for potential rounding
>> errors.
>>
>> Ralf
>>
>> _______________________________________________
>> Delphi Inspiration mailing list
>> yunqa@xxxxxxxxxxxxx
>> //www.freelists.org/list/yunqa
>>
>>
>>
>>
>

Other related posts: