How Are Unlimited Precision Integers Accomplished?

Michael Hudson mwh at python.net
Thu May 23 10:54:00 EDT 2002


Michael Chermside <mcherm at destiny.com> writes:

> Uncle_Alias writes:
>  > This [unlimited precision integers] is amazing to me that it can
>  > calculate integers to unlimited precision. How is this done?
> 
> Martin v. Loewis responds:
>  > It uses more memory for larger numbers.
>     ...
>  > Of course, you can't use processor instructions for operations on
>  > these numbers (directly), so Python implements its own +, -, *, /,
>  > etc.
> 
> For those of whose interest was piqued by this question, can someone
> elaborate with a simple summary of the data structure that is used,

Arrays of shorts, using 15 bits of each element, I think.

> the algorithms for performing the operations, 

Simple ones, I believe.

> and what senarios these are optimized for?

Getting the right answer (again, as I understand it).

Cheers,
M.

-- 
  MAN:  How can I tell that the past isn't a fiction designed to
        account for the discrepancy between my immediate physical
        sensations and my state of mind?
                   -- The Hitch-Hikers Guide to the Galaxy, Episode 12



More information about the Python-list mailing list