[fpc-pascal] FPC GO32 2.6.2 wrong result from SecondsBetween
Tomas Hajny
XHajT03 at hajny.biz
Tue Sep 17 20:31:19 CEST 2013
On Tue, September 17, 2013 20:22, Lubomír Čabla wrote:
> It may be, but I tried to use EncodeDateTime with the same result:
>
> DT1:=EncodeDateTime(2013,5,28,15,26,1,0);
> DT2:=EncodeDateTime(2013,5,28,15,27,1,0);
>
> Function EncodeDateTime calls TryEncodeDateTime that uses TryEncodeDate
> and
> TryEncodeTime.
>
> This is only a test, I want to be sure that after comparing the two values
> get the correct time difference and 59 seconds is not correct.
As a principle, you can never avoid such errors if using floating point
numbers. If you need absolutely precise results, use integers.
Tomas
>
> On Tue, Sep 17, 2013 at 6:15 PM, Bart <bartjunk64 at gmail.com> wrote:
>
>> On 9/17/13, Lubomír Čabla <kladno at gmail.com> wrote:
>> > I am doing something wrong?
>>
>> Probably rounding errors:
>> DT1:=EncodeDate(2013,5,28)+EncodeTime(15,26,1,0);
>> 2 calculations on floating numbers
>>
>> DT1:=EncodeTime(15,26,1,0);
>> 1 calculation on floating numbers
>>
>> Bart
>> _______________________________________________
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list