Floating point equality [was Re: What exactly is "exact" (was Clean Singleton Docstrings)]

Rustom Mody rustompmody at gmail.com
Thu Jul 21 01:28:17 EDT 2016


On Wednesday, July 20, 2016 at 11:13:05 AM UTC+5:30, Steven D'Aprano wrote:
> On Tuesday 19 July 2016 14:58, Rustom Mody wrote:
> 
> > So I again ask: You say «"Never compare floats for equality" is a pernicious
> > myth»
> 
> It is the word *never* which makes it superstition. If people said "Take care 
> with using == for floats, its often not what you want" I would have no argument 
> with the statement.
> 
> I'd even (reluctantly) accept "usually not what you want". But "never" is out-
> and-out cargo-cult programming.

You seem to not understand the realities of teaching.
You (teacher in general) cannot say a saga; only epigrams
You cannot transmit wisdom (even if you own some) just a bit of savviness/cleverness.

So let me ask the question again differently:
How many errors happen by people not using ε-neighborhood checks instead of == checks
How many errors happen by the opposite (mis)use?

IOW “myth”... ok “pernicious myth” Not

BTW APL whose main domain of application is scientific chooses to enshrine
this —equality is ε-neighborhood checking not exact equality checking — into its builtin ‘==’

And http://www.dyalog.com/uploads/documents/Papers/tolerant_comparison/tolerant_comparison.htm

ε is spelt ⎕ct (Comparison Tolerance)
And of course == is spelt =



More information about the Python-list mailing list