ZachB ZachB - 1 year ago 132
C++ Question

Check if argument passed to node C++ addon is Infinity or NaN

How do you check if an argument passed directly to a node C++ addon (not via a JS wrapper) is NaN or +/-Infinity?

I tried

frexp(arg[0]->NumberValue(), &exponent)
with the intent of checking if the exponent is 2047 (how JS represents NaN and Infinity), but evidently
obscures the double and changes the exp value.

Answer Source

For C++11 the reply is

std::isinf(x) || std::isnan(x)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download