Checking if a double (or float) is NaN in C++

后端 未结 21 2153
北恋
北恋 2020-11-22 05:10

Is there an isnan() function?

PS.: I\'m in MinGW (if that makes a difference).

I had this solved by using isnan() from , which doe

21条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 05:27

    The IEEE standard says when the exponent is all 1s and the mantissa is not zero, the number is a NaN. Double is 1 sign bit, 11 exponent bits and 52 mantissa bits. Do a bit check.

提交回复
热议问题