Re: Float comparison
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 22 Apr 2009 17:19:08 -0700
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"
.
- Follow-Ups:
- Re: Float comparison
- From: christian.bau
- 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: Keith Thompson
- Re: Float comparison
- From: Mark McIntyre
- Float comparison
- Prev by Date: Re: Float comparison
- Next by Date: Re: Float comparison
- Previous by thread: Re: Float comparison
- Next by thread: Re: Float comparison
- Index(es):
Relevant Pages
|