What is the rationale for all comparisons returning false for IEEE754 NaN values?

后端 未结 11 1951
耶瑟儿~
耶瑟儿~ 2020-11-21 07:04

Why do comparisons of NaN values behave differently from all other values? That is, all comparisons with the operators ==, <=, >=, <, > where one or both values is NaN

11条回答
  •  渐次进展
    2020-11-21 07:19

    To throw in yet another analogy. If I hand you two boxes, and tell you that neither of them contains an apple, would you tell me that the boxes contain the same thing?

    NaN contains no information about what something is, just what it isn't. Therefore these elements can never definitely be said to be equal.

提交回复
热议问题