确定NSNumber是否为NaN [英] Determine if NSNumber is NaN

查看:552
本文介绍了确定NSNumber是否为NaN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定Cocoa NSNumber是否代表NaN(不是数字)?



例如,当我解析一个无效的字符串因此,我发现类属性 [NSDecimalNumber notANumber] 只是为了这个目的。在某些语言中,NaN!= NaN,但在Cocoa中不是这样。


How can I determine if a Cocoa NSNumber represents NaN (not a number)?

This emerges, for example, when I parse a string that has an invalid (non-numeric) contents.

解决方案

So, I found out that the class property [NSDecimalNumber notANumber] is just for this purpose. In some languages NaN != NaN, but this isn't the case in Cocoa.

这篇关于确定NSNumber是否为NaN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆