Overflow error when printing long values

Steven D. Majewski sdm7g at Virginia.EDU
Thu Aug 30 11:47:09 EDT 2001


On Thu, 30 Aug 2001, Michael Teo wrote:

> I get an "OverflowError: long int too long to convert" when I tried to 
> print "%d" % l
> where l is a long Python value.
> 
> I have tried using str(l) but that gives a trailing 'L'.
> 
> Any good suggestion on how to solve this problem will be greatly
> appreciated. Thanks.
> 

It works for me -- what version of Python are you using?
-- Steve Majewski

Python 2.1.1 (#1, 07/20/01, 14:46:06) 
[GCC Apple DevKit-based CPP 6.0alpha] on darwin1
Type "copyright", "credits" or "license" for more information.
>>> big = long( 8.76e99 )         
>>> big
8759999999999999354471093662302337438821457945314428213916079963522740178689040274755268484706336768L
>>> "%d" % big
'8759999999999999354471093662302337438821457945314428213916079963522740178689040274755268484706336768'
>>> 








More information about the Python-list mailing list