Working with the set of real numbers

Grant Edwards invalid at invalid.invalid
Wed Feb 12 18:23:21 EST 2014


On 2014-02-12, Gregory Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Chris Angelico wrote:
>
>> Of course a computer can work with _some_ real numbers; but only
>> some. (An awful lot of them, of course. A ridiculously huge number of
>> numbers. More numbers than you could read in a lifetime! While the
>> number is extremely large, it still falls pitifully short of
>> infinity.[1])
>
> The number of integers it can work with is also vanishingly small
> compared to the total number of integers.
>
> However, the number of reals is vastly greater than the number of
> integers, so the proportion of reals it can work with is even *more*
> vanishingly small. In some sense.

More importantly, Computers can generally work with a subset of
integers consisting of all integers between a min value and a max
value. The min and max may be known and fixed at compile time (e.g. C
"int" on a 32-bit machine), or it may depend on how much memory and
time you have.  But knowing that you can represent all values in some
range makes life pretty easy.

OTOH, no matter how small the magnitude of the range of real numbers
you pick, computer FP can only represent a very tiny subset of the
rational numbers which are an even tinier subset of the real numbers
within whatever range you care to pick.  If you pick your range and
representation intelligently, you can still do some pretty useful
stuff. But, if you pretend you're actually working with real numbers
you will come a cropper.

-- 
Grant Edwards               grant.b.edwards        Yow! Why is it that when
                                  at               you DIE, you can't take
                              gmail.com            your HOME ENTERTAINMENT
                                                   CENTER with you??



More information about the Python-list mailing list