While refactoring some old Java code I noticed that a variable check for
Double was not doing what it was supposed to, in contrast to the code path for
Integer . That’s because where
Integer.MIN_VALUE really represents -2^31 the
Double.MIN_VALUE constant denotes actually the smallest positive nonzero value of type
Double (quoted from javadoc). Read this stackoverflow thread for more details. For
Double one has to use
-Double.MAX_VALUE to achieve the wanted result.
is licensed under Creative Commons BY-NC-SA 3.0.