Overflow error when printing long values
Michael Teo
michaelteo at bigfoot.com
Fri Aug 31 02:01:57 EDT 2001
I am using Python 1.5.2.
On Thu, 30 Aug 2001 23:47:09 +0800, Steven D. Majewski <sdm7g at Virginia.EDU> wrote:
>
>
>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'
>>>>
>
>
>
>
--
Michael Teo <mailto:michaelteo at bigfoot.com>
http://miketeo.net/
PGP 0x6C846A9C DB:7D:51:D4:4D:AB:97:79:E4:68:D9:07:94:36:D5:1A:6C:84:6A:9C
0x6937FB05 08:50:A1:4D:2E:45:58:60:DE:71:1F:30:63:54:EF:7B
More information about the Python-list
mailing list