Documentation of methods in java.lang.Number
andreas.lundblad at oracle.com
Tue Dec 16 12:55:09 UTC 2014
I've noticed that the documentation of Number.longValue says:
> Returns the value of the specified number as a long, which may involve rounding or truncation.
BigInteger and BigDecimal does not seem to honor this contract since they implement this method by masking out the lower bits of the number (and I've found no definition of "rounding" or "truncation" that encompass this behavuor). The documentation of these classes even state that "[...] this conversion can lose information about the overall magnitude of the BigInteger value as well as return a result with the opposite sign."
I suggest the documentation of Number.byteValue/shortValue/intValue/longValue should be updated to give room for this type of implementation.
(I filed an issue on this and got a confirmation email with the following link: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7000825 Since then this page has gone missing. Where did the bug report go, and why didn't I get any notification about the removal?)
-- Andreas Lundblad
More information about the core-libs-dev