Re: Float comparison
- From: Flash Gordon <smap@xxxxxxxxxxxxxxxxx>
- Date: Sat, 09 May 2009 09:39:21 +0100
Keith Thompson wrote:
CBFalconer <cbfalconer@xxxxxxxxx> writes:Keith Thompson wrote:
... snip ...
A stored value of type double cannot represent the real valueSo what? doubles are used to store reals, more or less. ints are
1.0+DBL_EPSILON/2.0, any more than a stored value of type int
can represent the value 1.5.
used to store integers. 1.0+DBL_EPSILON/2.0 is a real[1]. 1.5 is
NOT an integer.
[1] but not a storable real, in a double.
It's that "more or less" that bites you, isn't it? Your model makes
some sense if you ignore those pesky details where it falls apart.
<snip>
In addition doubles *are* used to store exact integral values and integer types *are* used to store approximations. Any claim that you have stored a range when you have in fact stored the exact value that you intended to store is clearly wrong and would make error analysis impossible.
Have you read C99 5.2.4.2.2 paragraphs 1-2? (In PDF or hard copy;
plain text doesn't show the formula.) Do you understand what it
means?
The model tells you whether you can store the exact values you would like to store (when that is what you want to do).
Please do not post a followup to this article without quoting and
responding to the previous paragraph, starting with "Have you read".
Yes, it would be helpful if CBF did not ignore most of the points being made.
--
Flash Gordon
.
- Follow-Ups:
- Re: Float comparison
- From: CBFalconer
- Re: Float comparison
- References:
- Re: Float comparison
- From: David Thompson
- Re: Float comparison
- From: CBFalconer
- Re: Float comparison
- From: Keith Thompson
- Re: Float comparison
- From: CBFalconer
- Re: Float comparison
- From: Keith Thompson
- Re: Float comparison
- From: CBFalconer
- Re: Float comparison
- From: Keith Thompson
- Re: Float comparison
- Prev by Date: Re: Create a Copy of Files
- Next by Date: Re: Create a Copy of Files
- Previous by thread: Re: Float comparison
- Next by thread: Re: Float comparison
- Index(es):
Relevant Pages
|