如何将NaN值变成另一个值? [英] How to change value NaN become the other value?
本文介绍了如何将NaN值变成另一个值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在除以两个0浮点数"时遇到问题,它们的结果为"NaN",这是错误吗?还是真实的结果?如果是真实结果,如何将其转换为数字?
i have problem in "divided two 0 float", the result from them is "NaN", is that an error? or real result? if real result, how to convert it become a number??
此处示例仅是代码
float val1=0,val2=0;
var result = val1/val2;
return result;
推荐答案
这应该为您解决问题:
This should do the trick for you:
if(Double.IsNaN(result))
{
//Assign new value here
}
这篇关于如何将NaN值变成另一个值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文