Boost logo

Boost Users :

Subject: Re: [Boost-users] isnan stopped working
From: Bernhard Walle (bernhard.walle_at_[hidden])
Date: 2009-01-05 05:05:56


* Thijs Koerselman [2009-01-04 23:11]:
>
> isnan() and family seems to have stopped working in my code. The only thing
> I can remember is updating from 1.36 to 1.37. Any idea why the following
> wouldn't work?
>
> float nan = FP_NAN;

That's just 3.

Use std::numeric_limits<float>::quiet_NaN() from <limits>. See the
example below that works for me on Linux with Boost 1.36 and g++ 4.3.2.

> int ret = 0xdeadbeef;
> ret = (boost::math::isnan)(nan);
>
> isnan never returns anything.

Well, in my tests on Linux that is set to 0 in your example.

Regards,
Bernhard

#include <iostream>
#include <limits>
#include <boost/math/special_functions/fpclassify.hpp>

int main(int argc, char *argv[])
{
    float nan = std::numeric_limits<float>::quiet_NaN();
    int ret = 0xdeadbeef;
    ret = (boost::math::isnan)(nan);

    std::cout << ret << std::endl;

    return 0;
}


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