[Zope] Weird interaction between int() and DateTime.timeTime
Jeff K. Hoffman
jeff.hoffman@goingv.com
Thu, 25 May 2000 13:32:15 -0400 (EDT)
On Thu, 25 May 2000 andres@corrada.com wrote:
> On Thu, May 25, 2000 at 12:56:48PM -0400, Shane Hathaway wrote:
> >
> > Simple: DateTime has been using floating-point calculations. I believe
> > all of that has been corrected, however, with the new DateTime module,
> > available in the public CVS repository.
> >
> > Shane
> >
>
> I don't understand how your answer explains the buggy behaviour. If
> DateTime.timeTime() returns a float that's okay. Why should a call to it
> wrapped with int() return the incorrect answer?
>
> >> t.timeTime()
> 953146937.0
> >> int( t.timeTime() )
> 953146936
> >> int( 953146937.0 )
> 953146937
Check this out:
Python 1.5.2 (#3, Mar 8 2000, 16:34:52) [C] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>
>>> f = 1.999999999999
>>> f
2.0
>>> int(f)
1
>>>
This was on one of our Solaris boxes. Apparently, the string
representation of a float having the value 1.999999999999 is 2.0, while
the int() function takes a different code path and returns 1, correctly.
I could be wrong, but I think that's what's biting you.
--Jeff
---
Jeff K. Hoffman 704.849.0731 x108
Chief Technology Officer mailto:jeff.hoffman@goingv.com
Going Virtual, L.L.C. http://www.goingv.com/