How Are Unlimited Precision Integers Accomplished?

Paul Rubin phr-n2002a at nightsong.com
Thu May 23 20:20:04 EDT 2002


zephinilium at yahoo.com (Uncle_Alias) writes:
> That explains part of my surprise: I'd been using an earlier version
> on the Mac, and am now using 2.2.1 on the PC.

Python has had longs since the beginning or thereabouts.  It's just
in 2.2 that ints convert to longs automatically on overflow.  Before
that, to get a long, you'd have to say (e.g.) "3L" to get the long
version of 3, instead of "3" for the int version.

> So what fun things can we do with this? Anyone have an algorithm for
> calculating pi?

You don't really need longs for that, especially if you want to compute
pi in hex.  There's a beautiful paper by Borwein, Bailey, and Plouffe
showing how to compute the (say) 1 billionth hex digit of pi, without
having to compute all the digits leading up to it.  I don't know
if anyone's figured out a way to do that in decimal though.



More information about the Python-list mailing list