1

I'm using C++ Builder XE and want to check a float value is valid. According to the help, in math.h, there's a call

bool IsNan(float value)

However, when I try to compile this, it tells me

Call to undefined function 'IsNan'

Looking in math.h, there's no such thing as isnan (I used a non-case sensitive search)

Am I doing something silly, or what ?

Joe
  • 41,484
  • 20
  • 104
  • 125
Nigel Stevens
  • 147
  • 1
  • 1
  • 9
  • 1
    http://stackoverflow.com/a/2123781/57135 – Joe Jan 24 '14 at 12:18
  • Basically: there is not consistent support for isnan; it's a macro in C99 (which some c++ compilers will let you use), and I believe it was added into C++11, but I don't know if C++Builder conforms to that yet/will ever. – Joe Jan 24 '14 at 12:20

2 Answers2

5

To use the Embarcadero inbuilt IsNan() function you need to include (for XE4 anyway)

#include <System.Math.hpp>

If you are using basic XE then you need

#include <Math.hpp>

The latter also works on XE4 although the help indicates that System.Math.hpp is needed.

mathematician1975
  • 21,161
  • 6
  • 59
  • 101
  • 2
    `Math.hpp` includes `System.Math.hpp` for backwards compatibility with pre-UnitScopeName code, that is why `Math.hpp` works on XE4 even though `System.Math.hpp` is actually needed. – Remy Lebeau Jan 24 '14 at 20:38
0

On the forum "Embarcadero Discussion Forums » C++Builder » C++ Language" Roger Dunk wrote: std::_isnan()

This solved the error for me ...

Dobedani
  • 508
  • 5
  • 20