-
Bug
-
Resolution: Fixed
-
P4
-
5.0
-
b71
-
x86
-
windows_xp, windows_vista
A DESCRIPTION OF THE PROBLEM :
The last two sentences of this javadoc read like this:
"Note that if the result of this method is passed to the string constructor, only the numerical value of this BigDecimal will necessarily be recovered; the representation of the new BigDecimal may have a different scale. In particular, if this BigDecimal has a positive scale, the string resulting from this method will have a scale of zero when processed by the string constructor."
This makes no sense because it would be an egregious bug if a BigDecimal constructed from a parsed String had a scale zero while the number represented by the original object had a positive scale. The last sentence should say "negative", instead of "positive". The method's source corroborates this:
public String toPlainString() {
BigDecimal bd = this;
if (bd.scale < 0)
bd = bd.setScale(0);
.........
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In particular, if this BigDecimal has a positive scale, the string resulting from this method will have a scale of zero when processed by the string constructor.
ACTUAL -
In particular, if this BigDecimal has a negative scale, the string resulting from this method will have a scale of zero when processed by the string constructor.
URL OF FAULTY DOCUMENTATION :
http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#toPlainString()
The last two sentences of this javadoc read like this:
"Note that if the result of this method is passed to the string constructor, only the numerical value of this BigDecimal will necessarily be recovered; the representation of the new BigDecimal may have a different scale. In particular, if this BigDecimal has a positive scale, the string resulting from this method will have a scale of zero when processed by the string constructor."
This makes no sense because it would be an egregious bug if a BigDecimal constructed from a parsed String had a scale zero while the number represented by the original object had a positive scale. The last sentence should say "negative", instead of "positive". The method's source corroborates this:
public String toPlainString() {
BigDecimal bd = this;
if (bd.scale < 0)
bd = bd.setScale(0);
.........
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In particular, if this BigDecimal has a positive scale, the string resulting from this method will have a scale of zero when processed by the string constructor.
ACTUAL -
In particular, if this BigDecimal has a negative scale, the string resulting from this method will have a scale of zero when processed by the string constructor.
URL OF FAULTY DOCUMENTATION :
http://java.sun.com/j2se/1.5.0/docs/api/java/math/BigDecimal.html#toPlainString()
- duplicates
-
JDK-6442680 writing error in 1.5 API specification
- Closed
- relates to
-
JDK-4984872 (jsr 13) BigDecimal needs toString method without exponents
- Resolved