Re: Float comparison



Mark McIntyre <markmcintyre@xxxxxxxxxxxxxxxxxxx> writes:
On 22/04/09 02:13, Keith Thompson wrote:

Given:
double x = 1.0;
the value of x is exactly 1.0, no more, no less.

No, you're incorrect there. The value is stored in a representation
which may, or may not, be capable of storing the value 1 exactly, but
the C standard doesn't require it to.

I believe it does. Take a look at C99 5.2.4.2.2, particularly
paragraphs 1 and 2. It defines a (fairly loose parameterized) model
for floating-point types. I think that any floating-point
representation that satisfies that model with the minimum
characteristics given later in that subsection must be able to
represent 1.0 exactly.

[...]

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: This calculation is just wrong / computer cant count!
    ... text as if it is "accurate" is meaningless. ... Any other representation and any interpretation in any other representation is ... because it has no representation in floating point. ... approximate, but incorrect, decimal value 0.83333333333333333 by a larger ...
    (microsoft.public.vc.mfc)
  • Re: Is continuum completely filled up?
    ... repeating sequence of coefficients in their representation; ... change the usual algorithm for multiplying; ... No, that's incorrect. ...
    (sci.math)
  • Re: Float comparison
    ... No, you're incorrect there. ... The value is stored in a representation ... but other coding schemes are allowable by the C standard. ... There are other factors of course (floating constants -- ...
    (comp.lang.c)
  • Re: This calculation is just wrong / computer cant count!
    ... because that is fewer bits of precision than an FPU implements. ... because it has no representation in floating point. ... approximate, but incorrect, decimal value 0.83333333333333333 by a larger ...
    (microsoft.public.vc.mfc)
  • Re: Bit shifts and endianness
    ... Mark McIntyre wrote: ... > For some reason RJH's original post didn't make it here. ... > response would have been " Rubbish", which is rare for a response to ... Er, guys, thats called a "representation". ...
    (comp.lang.c)