[Tutor] Picking Nits in "Learning to Program"
Roel Schroeven
rschroev_nospam_ml at fastmail.fm
Sat Feb 17 02:39:35 CET 2007
Carroll, Barry schreef:
> Alan:
>
> This is arguably a minor detail, and not directly related to Python
> but, hey, I'm a programmer. Minor details are my stock in trade. So
> here goes.
>
> In "Learning to Program", look at "The Raw Materials", "Real
> Numbers". The first sentence, "These are fractions" is technically
> incorrect, but incomplete. While it's true that fractions (i.e.
> rational numbers) are real numbers, there are far more real numbers
> that cannot be expressed as a ratio of two integers. Hence the name
> "Irrational Numbers". The square root of two is the prime example.
> (Sorry, can't do the math symbol in Plain Text.)
That's all true, but it's also that true that real numbers as they are
implemented in computers are not really real numbers. They are
implemented as binary fractions multiplied by some power of two (just
like scientific notation, but binary based instead of decimal based).
Have a look at http://en.wikipedia.org/wiki/IEEE_754 for the details.
That makes them effectively rational numbers or fractions. It's about
the best approximation for real numbers computers have to offer.
--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton
Roel Schroeven
More information about the Tutor
mailing list