[英]Is Double.MIN_VALUE is greater than zero in Java?
I found a bug in my code which boiled down to comparing Double(0.0)
with Double.MIN_VALUE
. 我在我的代码中发现了一个错误,它将Double(0.0)
与Double.MIN_VALUE
进行比较。 Essentially, the following returns false: 基本上,以下返回false:
System.out.println(0.0 > Double.MIN_VALUE);
How is this possible? 这怎么可能?
According to the javadoc for Double.MIN_VALUE , MIN_VALUE is: 根据Double.MIN_VALUE的javadoc ,MIN_VALUE是:
A constant holding the smallest positive nonzero value of type double 保持double类型的最小正非零值的常量
So Double.MIN_VALUE is not negative, it's the positive value that's as close as a Double can get to zero (without being zero). 所以Double.MIN_VALUE不是负数,它是正值,它可以接近于零(不为零)。
Double.MIN_VALUE是最小的正非零值,可以用Java double表示(请参阅http://download.oracle.com/javase/8/docs/api/java/lang/Double.html上的JavaDoc) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.