4511638: Double.toString(double) sometimes produces incorrect results

Reviewed-by: aturbanov, darcy, bpb
This commit is contained in:
Raffaello Giulietti 2022-06-01 21:53:54 +00:00 committed by Joe Darcy
parent 2f19144249
commit 72bcf2aa03
18 changed files with 4075 additions and 120 deletions

View file

@ -25,8 +25,10 @@
package java.lang;
import jdk.internal.math.FloatingDecimal;
import jdk.internal.math.DoubleToDecimal;
import jdk.internal.math.FloatToDecimal;
import java.io.IOException;
import java.util.Arrays;
import java.util.Spliterator;
import java.util.stream.IntStream;
@ -875,8 +877,13 @@ abstract sealed class AbstractStringBuilder implements Appendable, CharSequence
* @return a reference to this object.
*/
public AbstractStringBuilder append(float f) {
FloatingDecimal.appendTo(f,this);
try {
FloatToDecimal.appendTo(f, this);
} catch (IOException e) {
throw new AssertionError(e);
}
return this;
}
/**
@ -892,7 +899,11 @@ abstract sealed class AbstractStringBuilder implements Appendable, CharSequence
* @return a reference to this object.
*/
public AbstractStringBuilder append(double d) {
FloatingDecimal.appendTo(d,this);
try {
DoubleToDecimal.appendTo(d, this);
} catch (IOException e) {
throw new AssertionError(e);
}
return this;
}