蟒蛇南!=南

编程入门 行业动态 更新时间:2024-10-28 00:25:22
本文介绍了蟒蛇南!=南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = float('nan') >>> id(x) == id(x) True >>> x == x False

我对python中的nan != nan感兴趣.为了明确起见,我知道nan应该按照定义具有类似的行为,我是在问如何而不是为什么.在哪里实施?还有其他类似的对象吗?

I'm interested in how nan != nan in python. And just to clarify, I know nan is supposed to behave like that by definition, I'm asking about how not about why. Where is that implemented? Is there any other object which behaves like that?

推荐答案

对于问题的哪里"部分,请看Python 2.7.3源代码树中Objects/floatobject.c中的第391行.下面将对有关NaN == NaN的行为进行简要讨论.

For the "where" part of your questions, look starting at line 391 in Objects/floatobject.c in the Python 2.7.3 source tree. A brief discussion is given about the behavior of NaN == NaN with the implementation following.

对于表现出类似行为的其他情况,当然是可能的.但是,我没有对库进行详尽的搜索,因此无法给出确切的答案.

With respect to other cases that exhibit similar behavior, it is certainly possible. I have not done an exhaustive search of the libraries however, so I can't give a definitive answer.

更多推荐

蟒蛇南!=南

本文发布于:2023-10-31 00:46:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544497.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:蟒蛇

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!