Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -217,7 +217,7 @@ private FDBigInteger(int[] data, int offset) {
@ requires (\forall int i; 0 <= i && i < nDigits; '0' <= digits[i] && digits[i] <= '9');
@ ensures this.value() == \old(lValue * pow10(nDigits - kDigits) + (\sum int i; kDigits <= i && i < nDigits; (digits[i] - '0') * pow10(nDigits - i - 1)));
@*/
public FDBigInteger(long lValue, char[] digits, int kDigits, int nDigits) {
public FDBigInteger(long lValue, byte[] digits, int kDigits, int nDigits) {
int n = Math.max((nDigits + 8) / 9, 2); // estimate size needed.
data = new int[n]; // allocate enough space
data[0] = (int) lValue; // starting value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1034,10 +1034,10 @@ public float floatValue() {
static class ASCIIToBinaryBuffer implements ASCIIToBinaryConverter {
boolean isNegative;
int decExponent;
char digits[];
byte[] digits;
int nDigits;

ASCIIToBinaryBuffer( boolean negSign, int decExponent, char[] digits, int n)
ASCIIToBinaryBuffer( boolean negSign, int decExponent, byte[] digits, int n)
{
this.isNegative = negSign;
this.decExponent = decExponent;
Expand Down Expand Up @@ -1872,7 +1872,7 @@ static ASCIIToBinaryConverter readJavaFormatString( String in ) throws NumberFor
}
} // look for and process decimal floating-point string

char[] digits = new char[ len ];
byte[] digits = new byte[ len ];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
byte[] digits = new byte[ len ];
byte[] digits = new byte[len];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@turbanoff I'll apply your suggestions later, in PR 21840

boolean decSeen = false;
int nDigits = 0;
int decPt = 0;
Expand Down Expand Up @@ -1903,10 +1903,10 @@ static ASCIIToBinaryConverter readJavaFormatString( String in ) throws NumberFor
while (i < len) {
c = in.charAt(i);
if (c >= '1' && c <= '9') {
digits[nDigits++] = c;
digits[nDigits++] = (byte) c;
nTrailZero = 0;
} else if (c == '0') {
digits[nDigits++] = c;
digits[nDigits++] = (byte) c;
nTrailZero++;
} else if (c == '.') {
if (decSeen) {
Expand Down
10 changes: 5 additions & 5 deletions test/jdk/jdk/internal/math/FloatingDecimal/TestFDBigInteger.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -22,13 +22,13 @@
*/

import java.math.BigInteger;
import java.util.Random;
import java.nio.charset.StandardCharsets;
import jdk.internal.math.FDBigInteger;

/**
* @test
* @bug 7032154
* @summary unit testys of FDBigInteger
* @bug 7032154 8342693
* @summary unit tests of FDBigInteger
* @modules java.base/jdk.internal.math
* @author Dmitry Nadezhin
*/
Expand All @@ -52,7 +52,7 @@ public class TestFDBigInteger {
}

private static FDBigInteger mutable(String hex, int offset) {
char[] chars = new BigInteger(hex, 16).toString().toCharArray();
byte[] chars = new BigInteger(hex, 16).toString().getBytes(StandardCharsets.US_ASCII);
return new FDBigInteger(0, chars, 0, chars.length).multByPow52(0, offset * 32);
}

Expand Down