[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avrdude-dev] Adding elapsed time
From: |
Theodore A. Roth |
Subject: |
Re: [avrdude-dev] Adding elapsed time |
Date: |
Wed, 30 Jul 2003 11:57:35 -0700 (PDT) |
On Wed, 30 Jul 2003, Joerg Wunsch wrote:
> As Theodore A. Roth wrote:
>
> > It's usually a bad idea to test for equality with a float since the
> > equality may never be true due to the nature of floats (does 0 ==
> > 10^-400?).
>
> Comparision against constant 0.0 is guaranteed to work though. 0.0 is
> one of the FP numbers that has a fixed bit pattern, like +Inf, +NaN,
> -Inf, -NaN. Note that there's a +0.0 as well as a -0.0, but they are
> supposed to compare identical (which they don't do on the AVR, btw. --
> there are more lurking compatibility bugs in that respect, but that's
> merely off-topic here ;-).
>
> Other powers of two can also be compared exactly (1.0 for example),
> but that's already an implementation detail, while the mentioned
> absolute constants are IMHO guaranteed to exist and to be comparable
> by the IEEE standard.
I don't think that that invalidates my statement. As a casual user of
floating point math, I would rather stick to a general rule that works
in all cases than remember all the gory details that are only true is
certain circumstances. I find that this makes my code more
maintainable and bug free.
I can see one use of an equality check though, to check for div by
zero (kinda puedo-code, so don't consider it anything but a hack
example):
float reciprocal (float foo)
{
if (0.0 == foo)
return NaN;
else
return 1.0/foo;
}
This is why I don't use C++ or perl if I can help it. Too many
features to remember how to use them all correctly (to be honest,
python isn't much better in that respect). But that is _way_ off-topic
now. ;-)
Now, back on topic. I think Brian's second elapsed time patch is more
in tune with the design of the report_progress() function.
Ted Roth
- Re: [avrdude-dev] Adding elapsed time, (continued)
- Re: [avrdude-dev] Adding elapsed time, Brian Dean, 2003/07/29
- Re: [avrdude-dev] Adding elapsed time, Brian Dean, 2003/07/29
- Re: [avrdude-dev] Adding elapsed time, Theodore A. Roth, 2003/07/29
- RE: [avrdude-dev] Adding elapsed time, Alex Shepherd, 2003/07/29
- Re: [avrdude-dev] Adding elapsed time, Brian Dean, 2003/07/29
- RE: [avrdude-dev] Adding elapsed time, Alex Shepherd, 2003/07/30
- RE: [avrdude-dev] Adding elapsed time, Theodore A. Roth, 2003/07/30
- RE: [avrdude-dev] Adding elapsed time, Alex Shepherd, 2003/07/30
- Re: [avrdude-dev] Adding elapsed time, Brian Dean, 2003/07/30
- Re: [avrdude-dev] Adding elapsed time, Joerg Wunsch, 2003/07/30
- Re: [avrdude-dev] Adding elapsed time,
Theodore A. Roth <=
- Re: [avrdude-dev] Adding elapsed time, Joerg Wunsch, 2003/07/31
- RE: [avrdude-dev] Adding elapsed time, Alex Shepherd, 2003/07/29