Working with the set of real numbers

Dave Angel davea at davea.name
Wed Feb 12 17:56:53 EST 2014


 Gregory Ewing <greg.ewing at canterbury.ac.nz> Wrote in message:
> Chris Angelico wrote:
>> Sure, but nobody said the text file had to be _stored_ anywhere :)
>> Computers are quite capable of working with streams of incoming data
>> that are potentially infinite in size.
> 
> However, they *can't* work with arbitrary real numbers in an
> exact way, even if they are represented by infinitely long
> digit streams, and you're willing to run the program for
> an infinitely long time to get the result.
> 
> Consider adding two of these numbers, for example. You have
> to do it starting at the big end, because the small end is
> infinitely far away. And you only have a limited amount of
> buffer space, so you need to start writing out result
> digits before you've seen all the input digits.
> 
> But you can't do that, because it's possible that some
> pair of input digits you haven't seen yet will cause a
> carry-over that ripples back and affects something you've
> already written out.
> 
> 
Actually, the particular example you use can be done.  When
 printing the infinite sum of two infinite decimal streams,  you
 can simply hold back whenever you get one or more nines.  Instead
 keep a count of how many nines you're holding,  and emit them all
 only when you get something other than 9. I've done something
 analogous doing run length encoding of an rs232 stream.

But you're right in general. 


-- 
DaveA




More information about the Python-list mailing list