You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of Java 8 there is Math.toIntExact. This method forms an alternative to Guava's Ints.checkedCast, except that the former throws an ArithmeticException while the latter throws an IllegalArgumentException.
Suggestion: update the documentation of Ints.checkedCast to suggest Math.toIntExact as an alternative for Java 8 users, pointing out the caveat that this would change the exception behavior.
The text was updated successfully, but these errors were encountered:
Hmmm. This feels a little weird, largely because most of our classes in primitives have a checkedCast method, and it's only Ints that has an equivalent in Java 8. Eh, I think it's still worth it.
Should we consider adding this warning to the other (now obsolete) APIs in places like IntMath though? e.g., IntMath.checkedSubtract(a, b) -> Math.subtractExact(a, b)
As of Java 8 there is
Math.toIntExact
. This method forms an alternative to Guava'sInts.checkedCast
, except that the former throws anArithmeticException
while the latter throws anIllegalArgumentException
.Suggestion: update the documentation of
Ints.checkedCast
to suggestMath.toIntExact
as an alternative for Java 8 users, pointing out the caveat that this would change the exception behavior.The text was updated successfully, but these errors were encountered: