Boost logo

Boost :

Subject: Re: [boost] several messages
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2012-08-20 04:50:44


> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Dave
> Abrahams
> Sent: Sunday, August 19, 2012 1:52 AM
> To: boost_at_[hidden]
> Subject: Re: [boost] several messages
>
>
> on Wed Aug 08 2012, Marc Glisse <marc.glisse-AT-inria.fr> wrote:
>
> > On Wed, 8 Aug 2012, Dave Abrahams wrote:
> >
> >>> Most uses of a moved-from object I can think of other than
> >>> destruction and assignment are rather contrived. For a container, it
> >>> can make sense to look at its size and assign to the elements. For a
> >>> bignum, maybe if you are interested in an arbitrary number < y (to
> >>> pass it to a nextafter-like function), before setting x to y-1, you
> >>> could check if x<y and not want that to crash the program. If you
> >>> are going to use a bignum as a bitfield, the same argument as for
> >>> the container could be made.
> >>
> >> This sounds kind of like programming with iostreams whose badbit has
> >> been set. Lots of times it's possible to write the code so that it
> >> can barrel ahead as though nothing is wrong and only check for a
> >> problem much later. But it sounds kind of implausible that you'd be
> >> able to pick a value for empty bignums that would allow that in most
> >> or even many cases.
> >
> > Hi Dave,
> >
> > I am not sure what you mean here. The safe solution is that whenever
> > you move-construct from a bignum, you set it to zero (move-assignment
> > is a swap). I am not sure, but it sounds like you are saying this
> > wouldn't be safe?
>
> Not exactly. With floats, we have non-signalling NaN, which IIUC is used in exactly that way: you
might
> end up with a few NaNs in your big linear algebra solution but they might well turn out to be
unimportant.
> What you do know is that anything that touches them will also yield a NaN, sort of like anything
that uses
> a stream with badbit set yields a stream with badbit set. Zero doesn't work that way: after all,
it's an
> additive identity.

+1 for this view.

William Kahan and the rest of the IEE754 designers wisely built in the concept of NotANumber. It
provides protection against spurious, zero-information results.

And, as we have discovered in writing functions and distributions in Boost.Math, it is a big
simplification if all number systems also support a NaN concept, however it is implemented.

Paul

---
Paul A. Bristow,
Prizet Farmhouse, Kendal LA8 8AB  UK
+44 1539 561830  07714330204
pbristow_at_[hidden]

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