Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-05-16 23:11:21


"Robert Ramey" <ramey_at_[hidden]> writes:

>>> Its even worse, there is way to write portable code which will
>>> generate any specific one of the "undefined" types.
>>
>> numeric_limits<float>::quiet_NaN()
>>
>> Is "reasonably portable."
>
> hmm - what's "reasonable portable" is hard to get a concensus on.

Let's put it this way:

  if numeric_limits<float>::has_quiet_NaN is true,
  numeric_limits<float>::quiet_NaN() is a portable way to get a
  non-signaling NaN of type float. If
  numeric_limits<float>::has_quiet_NaN is false, there's no
  representation of float with a non-signaling NaN value on the
  implementation.

This is exactly as portable as an int with value 100,000:

  if numeric_limits<int>::max() >= 100000, int(100000) is a portable
  way to get an int with value 10000 non-signaling NaN. If
  numeric_limits<int>::max < 10000, there's no representation of int
  with value 100000 on the implementation.

I hope you'll agree that an int with value 100000 is not too exotic,
and that a program that expects to be able to handle such an int ain't
"broke."

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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