[Patches] [ python-Patches-1478364 ] Picky floats

SourceForge.net noreply at sourceforge.net
Fri Apr 28 14:33:22 CEST 2006


Patches item #1478364, was opened at 2006-04-28 07:33
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1478364&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Skip Montanaro (montanaro)
Assigned to: Nobody/Anonymous (nobody)
Summary: Picky floats

Initial Comment:
I came across a bug at work yesterday where I had
written:

    if not delta:
        return 0.0

where delta was a floating point number.  After a
series of calculations piling up round-off error it
took on a value on the order of 1e-8.  Not zero, but it
should have been.  The fix was easy enough:

    if abs(delta) < EPSILON:
        return 0.0

for a suitable value of EPSILON.

That got me to thinking...  I'm sure I have plenty of
other similar mistakes in my code.  (Never was much of
a numerical analysis guy...)  What if there was a
picky-float configure option that generated warnings if
you compared a float with either another float or an
int using "=="?  Does that make sense to try for
testing purposes?  The initial implementation seemed
straightforward enough, though I'm sure if this idea
merits any serious consideration it will need some more
work (at the least this behavior should probably be
user-enabled).


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1478364&group_id=5470


More information about the Patches mailing list