Boost logo

Boost :

Subject: Re: [boost] New Boost.XInt Library, request preliminary review
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2010-03-28 16:50:52


On 28 March 2010 03:56, Jeffrey Lee Hellrung, Jr. <jhellrung_at_[hidden]> wrote:
>
> If you are going to represent NaNs, you might as well represent +/-infinity
> and +/-0.  I think the principle of least surprise says to follow the
> semantics of IEEE floating point.  But the best short term solution might be
> to just throw an exception and not worry about NaN's or infinities for now.
>

What operations result in NaNs, anyways? Are there any whose
preconditions can't be trivially checked? The only ones that come to
mind are checking for 0 before division and checking for negatives
before taking a square root, both of which are just as easily checked
outside the operation as inside it.

So I'd say just throw instead of generating the NaN in the first
place. With unbounded integers there's no underflow or overflow to
worry about, so the advantage of the special values is questionable.
(And I could make a wrapper to add the special values -- NaN, +Inf,
-Inf, 1/+Inf, 1/-Inf -- if I needed.)


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