Boost logo

Boost :

From: Guillaume Melquiond (guillaume.melquiond_at_[hidden])
Date: 2006-05-15 15:30:53


Le lundi 15 mai 2006 à 12:10 -0700, Robert Ramey a écrit :
> Peter Dimov wrote:
>
> > It depends. Where do you draw the line? Is inf a number? Is -0.0 a
> > number? You have to have NaN if you want to be able to represent x/y
> > as a float.
>
> That's the problem. x/y is not a valid operation if y is equal to 0. So
> it can't be represented as a number.
>
> The fact that C++ permits such an operation makes C++ different
> than arithmetic. The fact that C++ uses operators like "/" and defines them
> similar to - but not identical to - the way they are defined by
> standard arithmetic is the source of all these problems. I say
> that C++ should be changed to so that the floats and operators which
> apply to them should implement what people expect from arithmetic operators.

"Standard arithmetic" defines infinitely precise operators on real
numbers. You cannot be seriously suggesting that C++ should stop using
floating-point numbers and switch to such an arithmetic. The C++ float
type is a *floating-point* type and as such it obeys the rules of
*floating-point* arithmetic. Whatever your expectations, you cannot do
anything about the fact that floating-point numbers have a limited range
and a limited precision. Because of those, they are unable to obey the
rules of a standard arithmetic (whatever it is).

Best regards,

Guillaume


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