Skip to content

Commit

Permalink
8170389: java.text.DigitList.getDouble() : Controversy between javado…
Browse files Browse the repository at this point in the history
…c and code

Reviewed-by: naoto, lancea
  • Loading branch information
justin-curtis-lu authored and naotoj committed Oct 7, 2022
1 parent 3466e99 commit d39d8c8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/java.base/share/classes/java/text/DigitList.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ public void append(char digit) {

/**
* 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) {
Expand All @@ -171,7 +171,8 @@ public final double getDouble() {

/**
* 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
Expand All @@ -195,6 +196,11 @@ public final long getLong() {
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) {
Expand Down

1 comment on commit d39d8c8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.