3

Please have a look at the following code

private List createTheDynamicWordList(String algorithm, double averageStat)
    {

        Toast.makeText(context, ""+averageStat, Toast.LENGTH_LONG).show();
}

in some cases, I get the averageStat as a 'NaN' value. I need to check whether the number if 'NaN' or not. How can I do this? Using NumberFormatException here didn't work.

4

2 回答 2

23

在你的情况下应该足够了:

   if (Double.isNaN(averageState))

看看这里

于 2013-08-20T09:01:20.577 回答
5

使用静态方法Double.isNaN()

于 2013-08-20T09:01:55.940 回答