Re: Float comparison
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Thu, 23 Apr 2009 20:50:22 -0400
Phil Carmody wrote:
CBFalconer <cbfalconer@xxxxxxxxx> writes:
Richard Heathfield wrote:
CBFalconer said:... snip ...
because that floating point value makes no assertion
about any exact value.
Values don't make assertions. Values just *are*. How we
interpret them is our business, not theirs.
<snip - and yes, I did read the bit I snipped, and no, I don't
think it's even remotely relevant. In fact, I think it's
gibberish.>
Well, since you seem happy processing gibberish, I will restore
the missing quote for the benefit of other readers.
It only asserts that the real value is between
established limits. Any other assertion comes from other
facts, such as the overall program structure. If you don't
realize this you will make serious usage errors.
What is the difference between the "real value" of a FP variable,
and simply its value?
#include <float.h>
double a, b;
...
a = 1.0;
b = a + (DBL_EPSILON / 2)
...
Now a and b display identical values. They did not have identical
values stored in them.
5.2.4.2.2 Characteristics of floating types <float.h>
....
[#10] The values given in the following list shall be
replaced by implementation-defined constant expressions with
(positive) values that are less than or equal to those
shown:
-- the difference between 1 and the least value greater
than 1 that is representable in the given floating
point type, b1-p
FLT_EPSILON 1E-5
DBL_EPSILON 1E-9
LDBL_EPSILON 1E-9
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
.
- Follow-Ups:
- Re: Float comparison
- From: Keith Thompson
- Re: Float comparison
- From: Ben Bacarisse
- Re: Float comparison
- References:
- Float comparison
- From: Alessio Ribeca
- Re: Float comparison
- From: CBFalconer
- Re: Float comparison
- From: Richard Heathfield
- Re: Float comparison
- From: CBFalconer
- Re: Float comparison
- From: Richard Heathfield
- Re: Float comparison
- From: CBFalconer
- Re: Float comparison
- From: Phil Carmody
- Float comparison
- Prev by Date: Re: Float comparison
- Next by Date: Re: adapting getline
- Previous by thread: Re: Float comparison
- Next by thread: Re: Float comparison
- Index(es):
Relevant Pages
|
Loading