可以将float(或double)设置为NaN吗? [英] Can float (or double) be set to NaN?
本文介绍了可以将float(或double)设置为NaN吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
注意:类似于整数在C ++中可以为NaN吗?
我了解这没有什么实际用途,但是可以将float
或double
设置为NaN
吗?
I understand this has little practical purpose, but can a float
or double
be set to NaN
?
推荐答案
Float对象包含一个静态值,该静态值是float
类型,称为NaN
.
The Float object contains a static value, which is a float
type, called NaN
.
所以
float myFloat = Float.NaN;
满足您的要求.
http://download.oracle. com/javase/6/docs/api/java/lang/Float.html#NaN
这篇关于可以将float(或double)设置为NaN吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文