Iphone `isNan`在Objective-C中
Objective-C是否有类似isNan(Javascript示例)的函数?我刚刚注意到这段代码导致显示Iphone `isNan`在Objective-C中,iphone,Iphone,Objective-C是否有类似isNan(Javascript示例)的函数?我刚刚注意到这段代码导致显示Nan%,因此我需要检测值是否为Nan,以便将其更改为0 [portefeuillePercentWaarde setText:[NSString stringWithFormat:@"%.2f%%", verschilPrencentage]]; 试着添加 #include <math.h> 投票以重复方式结束。好消息是另一个问题有你的答案:)@e.James:不是重复的:
Nan%
,因此我需要检测值是否为Nan,以便将其更改为0
[portefeuillePercentWaarde setText:[NSString stringWithFormat:@"%.2f%%", verschilPrencentage]];
试着添加
#include <math.h>
投票以重复方式结束。好消息是另一个问题有你的答案:)@e.James:不是重复的:你的链接是针对NSNumber的,这个问题是针对float/double的。Objective-C是针对float或double的:
isnan(verschilPrencentage)
;浮动点类型的Swift:verschilPrencentage.isNaN
。
double x;
// do some operation here
x = doSomething();
if (x != x)
printf("%g is probably NaN, it's not equal to itself\n", x);