jbcoe
jbcoe

Reputation: 3921

How is _isnan different to std::isnan on Visual Studio 2015

Visual Studio 2015 offers _isnan and std::isnan to check if a double is NaN.

Following VS's 'Go to Definition' does not end up in the same place for both functions and assembly output from a simple program that checks for NaN is not the same.

How is _isnan different to std::isnan? Which should I use when writing C++?

Upvotes: 3

Views: 1567

Answers (2)

jbcoe
jbcoe

Reputation: 3921

From private communication with James McNellis of Microsoft (posted with approval):

"They were integrated into the C Runtime at different points in time. _isnan was integrated some time ago along with a handful of other IEEE recommended functions; isnan was added later as part of the C99 additions.

If you find a case where either produces an incorrect result, please do file a bug at https://connect.microsoft.com/visualstudio/."

I conclude from this that _isnan and std::isnan should do the same thing.

Upvotes: 2

Techidiot
Techidiot

Reputation: 1947

_isnan is from Global Name Space which uses #include <float.h>

std::isnan is from Standard Name Space which uses #include <cmath>

You can use any one of them with Visual Studio 2015. Doesn't matter.

Refer this for more on this

Upvotes: 4

Related Questions