Re: Float comparison
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 08 May 2009 01:21:15 -0700
CBFalconer <cbfalconer@xxxxxxxxx> writes:
[...]
True, but we are talking about FP representation (and int
representation), which have other limitations, including maximum
and minimum values. ints don't have a range associated with each
value, the adjacent integer value is always available. Reals don't
have an adjacent value, but rationals do (they are countable). The
FP system is built on rationals, but cannot express the adjacent
rational. Neither the integer nor the FP system can handle the
infinities that exist in arithmetic.
Yes, rationals are countable, but no, they do not have adjacent
values. Given any two rational numbers x and y, the rational number
(x+y)/2 is between them and distinct from both of them. (I'm
referring to mathematical rational numbers here, not to any C
representation of them.)
However floating-point types do have adjacent values. For example,
1.0 and 1.0+DBL_EPSILON are adjacent values of type double; there are
no double values between them.
--
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: CBFalconer
- Re: Float comparison
- From: James Kuyper
- Re: Float comparison
- From: Richard Heathfield
- Re: Float comparison
- References:
- Re: Float comparison
- From: David Thompson
- Re: Float comparison
- From: CBFalconer
- Re: Float comparison
- Prev by Date: Re: What does a single colon mean in a function title?
- Next by Date: Re: Float comparison
- Previous by thread: Re: Float comparison
- Next by thread: Re: Float comparison
- Index(es):
Relevant Pages
|