8170389: java.text.DigitList.getDouble() : Controversy between javadoc and code

Reviewed-by: naoto, lancea
This commit is contained in:
Justin Lu 2022-10-07 22:58:26 +00:00 committed by Naoto Sato
parent 3466e99934
commit d39d8c856a

@ -153,8 +153,8 @@ final class DigitList implements Cloneable {
/**
* Utility routine to get the value of the digit list
* If (count == 0) this throws a NumberFormatException, which
* mimics Long.parseLong().
* If (count == 0) this returns 0.0,
* unlike Double.parseDouble("") which throws NumberFormatException.
*/
public final double getDouble() {
if (count == 0) {
@ -171,7 +171,8 @@ final class DigitList implements Cloneable {
/**
* Utility routine to get the value of the digit list.
* If (count == 0) this returns 0, unlike Long.parseLong().
* If (count == 0) this returns 0,
* unlike Long.parseLong("") which throws NumberFormatException.
*/
public final long getLong() {
// for now, simple implementation; later, do proper IEEE native stuff
@ -195,6 +196,11 @@ final class DigitList implements Cloneable {
return Long.parseLong(temp.toString());
}
/**
* Utility routine to get the value of the digit list.
* If (count == 0) this does not throw a NumberFormatException,
* unlike BigDecimal("").
*/
public final BigDecimal getBigDecimal() {
if (count == 0) {
if (decimalAt == 0) {