Re: Float comparison
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Fri, 08 May 2009 17:28:55 -0700
CBFalconer <cbfalconer@xxxxxxxxx> writes:
Keith Thompson wrote:[...]
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.
True again. Now all I want is for people to keep that (and the
consequences) in mind.
That's exactly what I've been doing. You should try it.
A stored value of type double cannot represent the real value
1.0+DBL_EPSILON/2.0, any more than a stored value of type int can
represent the value 1.5.
The computation 1.0/3.0 may yield any value within some
implementation-defined range. When the result of the computation is
stored in a double object, any range information is discarded; only a
single exact value (not exactly one third, but *some* exact value) is
stored.
--
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
- 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
- Prev by Date: Re: Float comparison
- Next by Date: Re: looking for thoughts on the philosophy of optimizing compilers
- Previous by thread: Re: Float comparison
- Next by thread: Re: Float comparison
- Index(es):