|
Boost : |
From: John Maddock (john_at_[hidden])
Date: 2006-05-16 05:27:33
Robert Ramey wrote:
> 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.
Hold on a second, C++ implements what the IEEE-754 standard requires FP
arithmetic to do, and infinities and NaN are definitely part of that
standard. I assure you that they do have legitimate uses, but more to the
point, it's not only divide by zero that generates infinities, heck even
addition (or subtraction) can generate infinities if push comes to shove.
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk