Boost logo

Boost :

Subject: [boost] Itanium floating point and negative NaN and changesign function
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2011-07-18 05:40:22


Antony Polukhin has done some great work on lexical_cast to make it work consistently with nonfinite
numbers (infinity and NaNs) without stringstream which required use of a globale C99 facet.

// Now try some 'round-tripping', 'reading' "inf"
  double x = boost::lexical_cast<double>("inf");
  // and check we get a floating-point infinity.
  BOOST_ASSERT(x == std::numeric_limits<double>::infinity());

now does what most people would expect.

All lexical_cast tests now pass on the popular platforms - except Itanium platform when parsing
-NaN, so

lexical_cast<std::basic_string<CharType> > (changesign)(std::numeric_limits<ValType>::quiet_NaN()) )
!= -nan

\boost-trunk\libs\math\test\test_lexical_cast.cpp

I don't access to this platform, or indeed any knowledge of it.

The test_sign.cpp which exercises changesign appears to work on this platform.

BOOST_CHECK((boost::math::signbit)((boost::math::changesign)(a)) != 0);

Can anyone expert on the platform shed any light on this?

My reading of some docs only mentions NaN, and never negative ones.

Is there anything special about the treatment of negative NaNs?

Paul

(There are those who believe that negative NaNs should not exist, but I have taken the other view
that it is more consistent to permit them, even if their meaning may be uncertain - the *signbit
does exist* on most platforms, and so is part of the 'payload' of some 7 (?) bits that the NaN
pattern carries. There are similar differences of view on signed zero, but most platforms permit
negative zero, mainly because there is a signbit, even for a value of zero.)

---
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