Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 2000-04-25 06:47:48


At 11:24 PM 4/24/00 -0400, Kevin Atkinson wrote:

>One well known problem with floating point numbers is that the
normal
>comparisons won't work when the equality case is important.
Therefore I
>propose a special adapter class be create called safe_double which
will
>act almost exactly like double (which includes implicit conversion
both
>ways) but will have "safe" comparison that will take into account
>rounding error. For example the ==, <, and <= would be defined as
>follows
>
>bool operator == (safe_double rhs, safe_double lhs)
> return abs(rhs-lhs) < SMALL_VAL

I'm almost totally ignorant of floating point semantics. Would the
above work correctly with if either or both rhs and lhs were NAN?

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk