Skip to content

Instantly share code, notes, and snippets.

@hellojinjie
Last active June 25, 2018 16:22
Show Gist options
  • Save hellojinjie/5873787 to your computer and use it in GitHub Desktop.
Save hellojinjie/5873787 to your computer and use it in GitHub Desktop.
Java 中判断 Double 是不是 NaN
// 哼,这是个坑,我会跟你说嘛。。。
Double num = Double.NaN
// :(
if (num == Double.NaN) {
System.out.println(num);
}
// :)
if (Double.isNaN(num)) {
System.out.println(num);
}
@pochichen
Copy link

thanks, it saves my time!

@blueclowd
Copy link

Thanks~

@twlkyao
Copy link

twlkyao commented Jul 11, 2016

== is not always ok.

@lyzenghq
Copy link

lyzenghq commented Sep 6, 2017

后一个好用

@kylema0421
Copy link

yep

@githubhao0705
Copy link

哈哈,谢谢~

@s-lion-h
Copy link

前来考古,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment