[egenix-users] Roundoff problem in DateTime

M.-A. Lemburg mal at lemburg.com
Tue Jul 9 18:47:30 CEST 2002


I've had a look at the problem: it seems that either the compiler
generates weird code or that the ALU in the processor has trouble
passing doube arguments on the stack:

The function doing the calculations shows a diff of abstime - 86400.0
of -0.00000000000545696821 and abstime >= 86400.0 is false. However,
once that value has been passed over the stack to another function,
the diff goes down to 0.0 and abstime == 86400.0 .... weird.

M.-A. Lemburg wrote:
> Reggie Dugard wrote:
> 
>> Sorry about that last e-mail, I included the attributes of the DateTime
>> instance BEFORE doing the addition (too little sleep I guess).  Here are
>> the ones you asked for.
> 
> 
> Thanks. I can reproduce the problem now.
> 
> I'll see whether I can find a fix for it. The problem is that
> leap seconds show as .abstime == 86400.0 as well, so whether
> or not a value is invalid is not straight forward to decide.
> 
>> On Mon, 2002-07-08 at 11:36, Reggie Dugard wrote:
>>
>>> I downloaded and compiled the beta 2 version of 2.1.0 and unfortunately
>>> it didn't help.  I've printed out all the attributes below, as you
>>> requested.
>>>
>>> Let me know if you need anything else.
>>>
>>> Reggie
>>>
>>>
>>> Python 2.2.1 (#1, Apr 29 2002, 15:21:53) [GCC 3.0.3] on linux2
>>> Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>>>> import mx.DateTime
>>>>>> mx.DateTime.__version__
>>>>>
>>>>>
>>> '2.1.0'
>>>
>>>>>> t = mx.DateTime.DateTimeFromAbsDateTime(730488,81317.647058823524)
>>>>>> t
>>>>>
>>>>>
>>> <DateTime object for '2001-01-03 22:35:17.65' at 8134e58>
>>
>>
>>
>>>>> t += 1.0/17.0
>>>>> t
>>>>
>>>>
>> <DateTime object for '2001-01-03 24:00:00.00' at 818b088>
>>
>>>>> for attr in t.__members__:
>>>>
>>>>
>> ...     print attr, ':', getattr(t,attr)
>> ... year : 2001
>> month : 1
>> day : 3
>> hour : 24
>> minute : 0
>> second : 0.0
>> absdays : 730488.0
>> absdate : 730488
>> abstime : 86400.0
>> yearoffset : 730485
>> is_leapyear : 0
>> day_of_week : 2
>> day_of_year : 3
>> days_in_month : 31
>> tz : PST
>> dst : 0
>> iso_week : (2001, 1, 3)
>> mjd : 51913.0
>> tjd : 1913.0
>> tjd_myriad : 245
>> jdn : 2451913.5
>> calendar : Gregorian
> 
> 


-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/




More information about the egenix-users mailing list