cushon / issues-import

0 stars 0 forks source link

Misuse of Double.MIN_VALUE and Float.MIN_VALUE #203

Open cushon opened 9 years ago

cushon commented 9 years ago

Original issue created by eaftan@google.com on 2013-10-30 at 08:50 PM


From Josh Bloch:

Double.MIN_VALUE and Float.MIN_VALUE do not actually provide the minimum double or float values. Instead, they provide the smallest positive nonzero value of the given type.

This is confusing, since Integer.MIN_VALUE behaves differently, and therefore most uses of Double/Float.MIN_VALUE are probably bugs.

cushon commented 9 years ago

Original comment posted by lowasser@google.com on 2013-10-30 at 08:59 PM


I like the idea, but I have no idea how this could be checked statically, unless you mean just banning these things entirely. Is there evidence that 90% of the uses of those constants are wrong?

cushon commented 9 years ago

Original comment posted by eaftan@google.com on 2013-10-30 at 10:12 PM


No, no evidence. I did a quick search of uses inside Google, and it's hard to tell what is and isn't a bug at a glance.

I just added this to track the idea. I'm not saying we should do it, just that it merits looking into.