Message82787
For a Decimal object (d), int(d) calls d.__int__(). In your example, d
has the attributes:
* _sign=1 (negative)
* _exp=0 (10^0=1)
* _int='2147483648'
d.__int__() uses s*int(self._int)*10**self._exp
<=> -(int('2147483648')). Since int('2147483648') creates a long, you
finally get a long instead of an integer.
Workaround to get a small integer even with -2147483648:
int(int(d)) ;-)
For me, it's not a bug because __int__() can return a long! The
following code works in Python 2.5 and 2.6:
class A:
def __int__(self):
return 10**20 |
|
Date |
User |
Action |
Args |
2009-02-26 23:32:57 | vstinner | set | recipients:
+ vstinner, theller, debedb |
2009-02-26 23:32:56 | vstinner | set | messageid: <1235691176.78.0.14029827293.issue5377@psf.upfronthosting.co.za> |
2009-02-26 23:32:55 | vstinner | link | issue5377 messages |
2009-02-26 23:32:54 | vstinner | create | |
|