What is the difference between IND and NAN numbers

只愿长相守 提交于 2019-12-23 10:25:13

问题


A NAN value means Not A Number and IND value means Indeterminate number. But what is the difference between these two. How can we represent both in c++.


回答1:


But what is the difference between these two.

They are both the same thing. Some platforms choose to display a non-number as some variant of NaN, while others choose to display it as some variant of IND.

How can we represent both in c++.

std::numeric_limits<double>::quiet_NaN() (or float or long double, if you prefer).




回答2:


If your operation would generate a larger positive number than could be stored in a double, the operation will return 1.#INF on Windows or inf on Linux

Some operations don't make mathematical sense, such as taking the square root of a negative number.Both sqrt(-1.0) and log(-1.0) would return a NaN, the generic term for a "number" that is "not a number".

Windows displays a NaN as -1.#IND ("IND" for "indeterminate") while Linux displays nan. Other operations that would return a NaN include 0/0, 0*∞, and ∞/∞.

Refernce Link1

Refernce Link2



来源:https://stackoverflow.com/questions/15288406/what-is-the-difference-between-ind-and-nan-numbers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!