0

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 Local<Value>->NumberValue() obscures the double and changes the exp value.

ZachB
  • 13,051
  • 4
  • 61
  • 89

1 Answers1

2

For C++11 the reply is

std::isinf(x) || std::isnan(x)
ZachB
  • 13,051
  • 4
  • 61
  • 89
marom
  • 5,064
  • 10
  • 14