Re: Float comparison



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.


.



Relevant Pages

  • Re: Float comparison
    ... Values don't make assertions. ... them is our business, not theirs. ... <snip - and yes, I did read the bit I snipped, and no, I don't think ... Well, since you seem happy processing gibberish, I will restore the ...
    (comp.lang.c)
  • Re: Float comparison
    ... Values don't make assertions. ... them is our business, not theirs. ... <snip - and yes, I did read the bit I snipped, and no, I don't think ... Well, since you seem happy processing gibberish, I will restore the ...
    (comp.lang.c)
  • Re: Was Jesus born 25th Dec AD 0?
    ... > I wish that some of the hundreds of people pushing out assertions on ... > webpages would get sceptical and start looking for the facts instead. ... of the Goddess....and is symbolic of both God energies and the sun ...
    (soc.religion.christian)
  • Re: Mahjong & Matiao Related? How and Why?
    ... "Clarifying some items" does not equal posting some assertions ... he copied it from Western historians' ...
    (rec.games.mahjong)
  • Re: Bipedalism in different substrates
    ... >>It wades less efficiently, it is not able to wade in as deep water, it ... >You make three claims - all unsupported assertions. ...
    (sci.anthropology.paleo)

Loading