Re: Double comparison problem
From: Dietmar Kuehl (dietmar_kuehl_at_yahoo.com)
Date: 01/19/05
- Next message: Gernot Frisch: "Re: Mixing new/delete and operator new/delete?"
- Previous message: Jerry Coffin: "Re: Employer looking 4 online C++ aptitude tests; recommendations?"
- In reply to: chris: "Re: Double comparison problem"
- Next in thread: chris: "Re: Double comparison problem"
- Reply: chris: "Re: Double comparison problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Jan 2005 05:44:46 -0800
chris wrote:
> There are two groups of people in this world.
>
> 1) Those who don't fully understand all of the details about
performing
> == and != on floating points values. They should never use == or !=
on
> floating point values (not being mean or anything, they just
shouldn't).
>
> 2) Those who do understand all the details about performing == and !=
on
> floating point values. They don't use == and !=, so don't have to be
> told not to :)
I'd say you fall into the first group! After all, comparing floating
point values representing reasonably sized integers is perfectly
valid even using '==' or '!=': you can use floating point values as a
form of bigger integer. You just have to take care of the values
staying in a certain range. Actually, you can also do exact
computations
for other values, i.e. those which can represented exactly. The only
thing to note is that the set of useful values is not closed over the
operations and you need to realize when the result of the operation is
of different kind (e.g. when addition or multiplication overflows,
substraction cancels leading bits, and division is only valid for
certain value). Sure enough, for most of my uses I don't play tricks
with floating point values but it is still possible and if you e.g.
need a 64 bit integer on a platform not supporting some form of
"long long" it can be an appropriate choice to use a 'long double'.
-- <mailto:dietmar_kuehl@yahoo.com> <http://www.dietmar-kuehl.de/> <http://www.contendix.com> - Software Development & Consulting
- Next message: Gernot Frisch: "Re: Mixing new/delete and operator new/delete?"
- Previous message: Jerry Coffin: "Re: Employer looking 4 online C++ aptitude tests; recommendations?"
- In reply to: chris: "Re: Double comparison problem"
- Next in thread: chris: "Re: Double comparison problem"
- Reply: chris: "Re: Double comparison problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|