Boost logo

Boost Users :

Subject: [Boost-users] Boost Units initialize quantity with signaling NaN
From: Belcourt, Kenneth (kbelco_at_[hidden])
Date: 2016-08-10 22:55:26


Hi,

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

Has anyone encountered this or know of a more elegant solution than modifying the quantity.hpp header?

— 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