Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misuse of Double.MIN_VALUE and Float.MIN_VALUE #203

Open
cushon opened this issue Oct 31, 2014 · 2 comments
Open

Misuse of Double.MIN_VALUE and Float.MIN_VALUE #203

cushon opened this issue Oct 31, 2014 · 2 comments

Comments

@cushon
Copy link
Collaborator

cushon commented Oct 31, 2014

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
Copy link
Collaborator Author

cushon commented Oct 31, 2014

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
Copy link
Collaborator Author

cushon commented Oct 31, 2014

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.

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

No branches or pull requests

1 participant