PSA - Double.MIN_VALUE is positive!

by cmur2 on 2015-12-21 in Java

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.

The post »PSA - Double.MIN_VALUE is positive!«
is licensed under Creative Commons BY-NC-SA 3.0.

cmur2

https://www.mycrobase.de/

GitHub