Boost logo

Boost Users :

From: me22 (me22.ca_at_[hidden])
Date: 2005-08-30 00:06:17


On 29/08/05, Steven Solie <ssolie_at_[hidden]> wrote:
> The std::equal() call is comparing an array of doubles using
> operator == which I thought was impossible for floating point types
> due to their inexact nature et al.
>

A (radix 2) floating-point number will never be exactly equal to one
seventh, for example, because it's not representable. The other issue
is that roundoff error will make things such as 1./3*3 not result in
exactly 1.

That doesn't mean that you can't compare between them for equality.
If one float is a copy of another, then they should be bitwise equal.
Also, floating-point operations are deterministic, so the same
sequence of operations -- in exactly the same environment -- should
also yeild bitwise equal results.

Since, afaik, PRNGs should only be equal because one is a copy of
another or they're at the same point in their cycle, operator== should
be fine.

- Scott McMurray


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net