Why isn't Python king of the hill?

Bob Drzyzgula bob at drzyzgula.org
Sat Jun 2 21:34:41 EDT 2001

On Sat, Jun 02, 2001 at 09:52:57PM +0000, Grant Edwards wrote:
> On Sat, 2 Jun 2001 21:28:45 +0000 (UTC), E. Mark Ping <emarkp at CSUA.Berkeley.EDU> wrote:
> >>So do I.  But every time I've seen an application _depend_ on exact
> >>representations, its caused problems.  Perhaps the FP code you've
> >>seen was better, but in my experience code that depends on exact
> >>represention has caused problems.
> >
> >Ah, but your example was exact representation of *integers*, not just
> >any value.
> What I've seen happen: code is written by a programmer who
> knows that the input values are going to be integer values that
> can be represented exactly.  It works fine for a few years.

One occasionally useful source of solid thought on this
issue is of course Knuth's Seminumerical Algorithms,
Chapter 4, "Arithmetic". Knuth goes so far as to refuse to
use the normal operators +, -, x and / for floating point
operations (from Section 4.2.1, 3/e):

   Since floating point is inherently approximate, not
   exact, we will use "round" symbols [graphic of the
   normal operators with circles drawn around them] to
   stand for floating point addition, subtraction...

At the beginning of section 4.2.2, he goes on:

   Floating point computation is by nature inexact, and
   programmers can easily misuse it so that the computed
   answers consist almost entirely of "noise". One of the
   principal problems of numerical analysis is to determine
   how accurate the results of certain numerical methods
   will be. There's a credibility gap. We don't know
   how much of the computer's answers to believe. Novice
   computer users solve the problem by implicitly trusting
   the computer as an infallible authority; they tend
   to believe that all digits of a printed answer are
   significant. Disillusioned computer users have just
   the opposite approach; they are constantly afraid that
   their answers are almost meaningless. Many serious
   mathematicians have attempted to analyze a sequence of
   floating point operations rigorously, but have found the
   task so formidable that they have tried to be content
   with plausibility arguments instead.

Knuth of course goes on to explain, in mind-numbing
detail, *exactly* "how much of the computer's
answers to believe"...

That chapter also includes around eighty pages on
rational arithmetic, FWIW.

Yes-i'm-new-to-this-list-please-don't-hit-me-ly y'rs,

--Bob Drzyzgula

More information about the Python-list mailing list