-
Notifications
You must be signed in to change notification settings - Fork 781
Description
Original issue created by kevinb@google.com on 2013-04-04 at 03:45 PM
Fact: some percentage of all occurrences of "(a + b) / 2" out there are bugs, or bugs waiting to happen.
(http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html)
Unfortunately, there's no reasonable fix we can suggest that is guaranteed to work for all possible values of a and b... except Guava's IntMath.mean(a, b) / LongMath.mean(a, b) methods.
If there is ever a place in error-prone for "checks for which the fix requires Guava", then it might be worth having a check that forces users of "(a + b) / 2" to change to use mean(). Most of those users probably weren't vulnerable to the bug, but we can't tell which they are.
If we don't do this, we'll probably just have to give up on ever catching that bug, and we will sadly probably give up on these Guava methods entirely, because literally NO ONE is using them (why would they? They already know how to get the mean of two numbers!).