Re: RFR: 8233760: Result of BigDecimal.toString throws overflow exception on new BigDecimal(str) [v2]

2022-06-07 Thread Joe Darcy
On Fri, 27 May 2022 22:59:47 GMT, Raffaello Giulietti  
wrote:

>> BigDecimal(String) currently fails to accept some strings produced by 
>> BigDecimal.toString(). This PR removes this limitation.
>
> Raffaello Giulietti has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   8233760: Result of BigDecimal.toString throws overflow exception on new 
> BigDecimal(str)

Marked as reviewed by darcy (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/8905


Re: RFR: 8233760: Result of BigDecimal.toString throws overflow exception on new BigDecimal(str) [v2]

2022-06-07 Thread Raffaello Giulietti
On Fri, 27 May 2022 22:59:47 GMT, Raffaello Giulietti  
wrote:

>> BigDecimal(String) currently fails to accept some strings produced by 
>> BigDecimal.toString(). This PR removes this limitation.
>
> Raffaello Giulietti has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   8233760: Result of BigDecimal.toString throws overflow exception on new 
> BigDecimal(str)

Hello,

here's an explanation of the changes in `BigDecimal`.

Rather than keeping track of a local `int scl` (scale) and a local `long exp` 
(exponent), the change only keeps track of a `long scl`, adapting it 
accordingly. It checks the range of `scl` before initializing the fields. This 
makes for a simpler code.

In addition, I couldn't resist changing C-style arrays to Java style over the 
whole class.

-

PR: https://git.openjdk.java.net/jdk/pull/8905


Re: RFR: 8233760: Result of BigDecimal.toString throws overflow exception on new BigDecimal(str) [v2]

2022-05-27 Thread Raffaello Giulietti
On Fri, 27 May 2022 20:16:12 GMT, Joe Darcy  wrote:

>> Raffaello Giulietti has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   8233760: Result of BigDecimal.toString throws overflow exception on new 
>> BigDecimal(str)
>
> test/jdk/java/math/BigDecimal/StringConstructor.java line 69:
> 
>> 67: constructWithError("0.01e"+Integer.MIN_VALUE);
>> 68: constructWithError("1e"+((long)Integer.MIN_VALUE-1));
>> 69: 
> 
> Please add some test cases to demonstrate that the round-tripping that 
> previous did not work is functional after the fix.

Tests were added in the new commit.

-

PR: https://git.openjdk.java.net/jdk/pull/8905


Re: RFR: 8233760: Result of BigDecimal.toString throws overflow exception on new BigDecimal(str) [v2]

2022-05-27 Thread Raffaello Giulietti
> BigDecimal(String) currently fails to accept some strings produced by 
> BigDecimal.toString(). This PR removes this limitation.

Raffaello Giulietti has updated the pull request incrementally with one 
additional commit since the last revision:

  8233760: Result of BigDecimal.toString throws overflow exception on new 
BigDecimal(str)

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/8905/files
  - new: https://git.openjdk.java.net/jdk/pull/8905/files/e82cece0..2a25c359

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=8905=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=8905=00-01

  Stats: 22 lines in 1 file changed: 21 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8905.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8905/head:pull/8905

PR: https://git.openjdk.java.net/jdk/pull/8905


Re: RFR: 8233760: Result of BigDecimal.toString throws overflow exception on new BigDecimal(str)

2022-05-27 Thread Joe Darcy
On Thu, 26 May 2022 18:02:14 GMT, Raffaello Giulietti  
wrote:

> BigDecimal(String) currently fails to accept some strings produced by 
> BigDecimal.toString(). This PR removes this limitation.

test/jdk/java/math/BigDecimal/StringConstructor.java line 69:

> 67: constructWithError("0.01e"+Integer.MIN_VALUE);
> 68: constructWithError("1e"+((long)Integer.MIN_VALUE-1));
> 69: 

Please add some test cases to demonstrate that the round-tripping that previous 
did not work is functional after the fix.

-

PR: https://git.openjdk.java.net/jdk/pull/8905


Re: RFR: 8233760: Result of BigDecimal.toString throws overflow exception on new BigDecimal(str)

2022-05-26 Thread Raffaello Giulietti
On Thu, 26 May 2022 18:02:14 GMT, Raffaello Giulietti  
wrote:

> BigDecimal(String) currently fails to accept some strings produced by 
> BigDecimal.toString(). This PR removes this limitation.

This happens because the constructor currently only accepts exponents in the 
`int` range (more precisely, in the open range (-2^31, 2^31)).
It should accept a larger range of exponents, as long as the resulting 
`BigDecimal` has a scale in the `int` range.

-

PR: https://git.openjdk.java.net/jdk/pull/8905