[Baypiggies] Numeric precision (was Re: Eric Raymond likes Python)
echerlin at gmail.com
Wed Sep 9 23:57:27 CEST 2009
APL has a default Print Precision for just this reason, and a way for
the user to set the number of digits to print throughout a workspace.
Explicit numeric formatting was also built in. We tend to get more
people who have at least heard of Numerical Analysis in the APL
community. Ken Iverson was of the opinion that the rudiments of NA
(significant digits, anyway) should be taught in grade school, and did
so himself in an IBM experiment in the 1960s.
On Sun, Sep 6, 2009 at 5:13 PM, Delbert Franz<ddf at iqdotdt.com> wrote:
> The complaint about 1.1 printing as 1.10...01, is just plain lame!
> When I ask for a variable to be printed without a format given,
> I want all of what the variable contains. The protester needs a
> simple lesson in floating point arithmetic. Of course too many
> people in software know practically nothing of floating point and
> expect the computer to behave like the "real number" system.
> Simple answer: it does not and never will:) Get a life and
> print with a format that cuts off the unavoidable floating-point
> noise! If it helps any, gfortran does the same thing and I suspect
> any other Fortran implementation worth anything would do the same thing.
> I suspect many developers were never taught much about floating point or if they
> were, they have forgotten about it.
Far too many classes on and books about programming languages only
think to teach the syntax, not the nature of data objects or anything
else beyond the most superficial semantics. I blame the schools for
teaching children that math is too hard for them, instead of teaching
how to learn it effectively in a way that suits each individual
child's cognitive style.
Sure, advanced math is hard. Like anything important, it is as hard as
possible, but no harder. Playing baseball, or the piano, or World of
Warcraft, for example. We don't say, "I won't learn as much as I can"
of anything we like, just because the pros are so much better at it.
Unless peer pressure or institutional pressure says we shouldn't.
> Being a "number cruncher" requires
> a nearly constant awareness of the various pitfalls of ignoring the
> differences between floating-point arithmetic and real-number
> system arithmetic.
Yup. Subtraction is one of the worst. What's 1.000001 - 1.000000 to
four significant figures? 0.0000. (The 0 before the decimal point
doesn't count.) What does the computer give you? 1.000e-6, unless you
know how to tell it in much greater detail what you really want, which
involves the intermediate stage, 1.000-1.000.
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
Edward Mokurai (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) Cherlin
Silent Thunder is my name, and Children are my nation.
The Cosmos is my dwelling place, the Truth my destination.
More information about the Baypiggies