|
Boost Users : |
Subject: Re: [Boost-users] Boost Units initialize quantity with signaling NaN
From: Belcourt, Kenneth (kbelco_at_[hidden])
Date: 2016-08-12 21:27:48
> On Aug 10, 2016, at 8:55 PM, Belcourt, Kenneth <kbelco_at_[hidden]> wrote:
>
> Iâm trying to find a way to initialize a Boost Unit with a signaling NaN, not just a NaN with the signal cleared. It seems that the only way to initialize a quantity is by multiplying by the unit, and that multiplication clears the signal on the NaN. I know I can just modify the quantity.hpp header and initialize the default constructor val_ member with the signaling NaN, but I was hoping for a cleaner solution.
>
> Hereâs an example (typed in by hand, not tested):
>
> const double s_nan = std::numeric_limits<double>::signaling_NaN();
>
> typedef quantity<si::acceleration, double> acceleration_t;
> BOOST_UNITS_STATIC_CONSTANT(acceleration_u, acceleration);
>
> acceleration_t a(s_nan * acceleration_u); // <â this clears the signal on the NaN
A little more info about this problem. We have customers with Boost installs that we canât modify (i.e. we canât copy quantity.hpp into their Boost install) and we canât ship a copy of Boost because building Boost MPI for our customerâs system is quite complicated. We use this signaling nan technique when our customers report problems running our codes. This requires me to find a way to enable the signaling NaN in quantity.hpp when those customers report having problems.
Weâd like to (1) use a macro to enable signaling nan initialization in quantity.hpp and (2) detect if our customerâs Boost install doesnât support this signaling nan macro. The attached test case demonstrates one way to support these two use cases (test case runs on MBP). Would there be any interest in trying to add this capability to Boost Units?
â Noel
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