Review: JDK 8 CR for Support Integer overflow updated (original) (raw)

Jeff Hain jeffhain at rocketmail.com
Tue Feb 14 20:08:11 UTC 2012


For "toInt" method(s), and other methods that don't involve mathematical operations but just transtyping, I think the naming conventions I was talking about (xxxInRange/xxxToRange for add/substract/multiply/negate/increment/etc.) don't need to apply.

One could just use "asInt" for the throwing version, and "toInt" for the non-throwing version. "toInt" can also be interpreted as "to int range" (and not only "to int type"), which matches what it would do then, and "toInt" is also the first method name that comes to mind when wanting to cast a long to an int, as one can cast a double to an int (or to a long), which in Java also does not throw an exception if the specified value is out of range, but returns the closest one.

Jeff



More information about the core-libs-dev mailing list