Re: RFR: 8273346: Expand library mappings to IEEE 754 operations [v2]

2022-06-06 Thread Joe Darcy
On Thu, 2 Jun 2022 08:22:11 GMT, Raffaello Giulietti  
wrote:

>> src/java.base/share/classes/java/lang/Math.java line 823:
>> 
>>> 821:  * @apiNote
>>> 822:  * This method corresponds to the convertTowardPositive operation
>>> 823:  * defined in IEEE 754.
>> 
>> Probably what is meant is IEEE `convertToIntegerTowardPositive` (not 
>> `convertTowardPositive`).
>> However, that's another kind of rounding, which always rounds any 
>> non-integral value toward positive infinity, not just ties. This is not what 
>> happens with this method.
>
>> not just ties
> Plz. disregard this 3 words

Okay, checking the IEEE 754-2019 spec again, there are operations to round a 
floating-point value to an integral-valued floating-point value 
(roundToIntegral{$ROUNDING_DIRECTION_ATTRIBUTE} and separately operations to 
round from a floating-point value to a value in an integer format 
(convertToInteger{$ROUNDING_DIRECTION_ATTRIBUTE} ). However, as noted, there is 
no IEEE 754 operations for rounding up only for ties. I'll remove the API notes 
for the round methods; thanks for catching this.

-

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


Re: RFR: 8273346: Expand library mappings to IEEE 754 operations [v2]

2022-06-02 Thread Raffaello Giulietti
On Wed, 1 Jun 2022 08:39:44 GMT, Raffaello Giulietti  
wrote:

> not just ties
Plz. disregard this 3 words

-

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


Re: RFR: 8273346: Expand library mappings to IEEE 754 operations [v2]

2022-06-01 Thread Raffaello Giulietti
On Wed, 1 Jun 2022 02:05:40 GMT, Joe Darcy  wrote:

>> Generally add apiNote's to map from Java library methods to particular IEEE 
>> 754 operations. For now, I only added such notes to java.lang.Math and not 
>> java.lang.StrictMath.
>
> Joe Darcy has updated the pull request with a new target base due to a merge 
> or a rebase. The incremental webrev excludes the unrelated changes brought in 
> by the merge/rebase. The pull request contains four additional commits since 
> the last revision:
> 
>  - Respond to review feedback; make another pass to link methods to IEEE 754 
> operations.
>  - Merge branch 'master' into JDK-8273346
>  - Add floor and ceil.
>  - JDK-8273346: Examine use of "rounding mode" and "rounding policy" in Math 
> and StrictMath

src/java.base/share/classes/java/lang/Math.java line 823:

> 821:  * @apiNote
> 822:  * This method corresponds to the convertTowardPositive operation
> 823:  * defined in IEEE 754.

Probably what is meant is IEEE `convertToIntegerTowardPositive` (not 
`convertTowardPositive`).
However, that's another kind of rounding, which always rounds any non-integral 
value toward positive infinity, not just ties. This is not what happens with 
this method.

-

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


Re: RFR: 8273346: Expand library mappings to IEEE 754 operations [v2]

2022-05-31 Thread Joe Darcy
On Wed, 25 May 2022 08:56:27 GMT, Raffaello Giulietti  
wrote:

>> Joe Darcy has updated the pull request with a new target base due to a merge 
>> or a rebase. The incremental webrev excludes the unrelated changes brought 
>> in by the merge/rebase. The pull request contains four additional commits 
>> since the last revision:
>> 
>>  - Respond to review feedback; make another pass to link methods to IEEE 754 
>> operations.
>>  - Merge branch 'master' into JDK-8273346
>>  - Add floor and ceil.
>>  - JDK-8273346: Examine use of "rounding mode" and "rounding policy" in Math 
>> and StrictMath
>
> src/java.base/share/classes/java/lang/Math.java line 771:
> 
>> 769:  * This method corresponds to the convertToIntegerTiesToEven
>> 770:  * operation defined in IEEE 754.
>> 771:  *
> 
> IEEE `convertToIntegerTiesToEven` rounds ties to the even integer.
> The method's spec, however, requires ties to round toward positive infinity.
> Unfortunately, IEEE 754 doesn't offer a `convertToIntegerTiesToPositive`

Good catch; found a different 754 operation that seems to fit.

> src/java.base/share/classes/java/math/RoundingMode.java line 49:
> 
>> 47:  * exponent range of {@code BigDecimal}, the mathematical result will
>> 48:  * be exactly representable in the result precision or fall between
>> 49:  * two representable values. In the case of falling between two
> 
> Perhaps better would be
> `two adjacent representable values.`

Agreed; adjusted in subsequent push.

-

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


Re: RFR: 8273346: Expand library mappings to IEEE 754 operations [v2]

2022-05-31 Thread Joe Darcy
On Wed, 1 Jun 2022 02:05:40 GMT, Joe Darcy  wrote:

>> Generally add apiNote's to map from Java library methods to particular IEEE 
>> 754 operations. For now, I only added such notes to java.lang.Math and not 
>> java.lang.StrictMath.
>
> Joe Darcy has updated the pull request with a new target base due to a merge 
> or a rebase. The incremental webrev excludes the unrelated changes brought in 
> by the merge/rebase. The pull request contains four additional commits since 
> the last revision:
> 
>  - Respond to review feedback; make another pass to link methods to IEEE 754 
> operations.
>  - Merge branch 'master' into JDK-8273346
>  - Add floor and ceil.
>  - JDK-8273346: Examine use of "rounding mode" and "rounding policy" in Math 
> and StrictMath

I look another pass over the methods in Float, Double, and Math for 
opportunities to link to IEEE 754 operations. At least for now, I choose not to 
link to abs since IEEE 754 abs can have different behavior for NaN values that 
java.lang.Math.abs. If a link is made, this difference would need to be noted.

-

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


Re: RFR: 8273346: Expand library mappings to IEEE 754 operations [v2]

2022-05-31 Thread Joe Darcy
> Generally add apiNote's to map from Java library methods to particular IEEE 
> 754 operations. For now, I only added such notes to java.lang.Math and not 
> java.lang.StrictMath.

Joe Darcy has updated the pull request with a new target base due to a merge or 
a rebase. The incremental webrev excludes the unrelated changes brought in by 
the merge/rebase. The pull request contains four additional commits since the 
last revision:

 - Respond to review feedback; make another pass to link methods to IEEE 754 
operations.
 - Merge branch 'master' into JDK-8273346
 - Add floor and ceil.
 - JDK-8273346: Examine use of "rounding mode" and "rounding policy" in Math 
and StrictMath

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/8876/files
  - new: https://git.openjdk.java.net/jdk/pull/8876/files/050e6ecd..9169ad9e

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

  Stats: 46471 lines in 566 files changed: 22606 ins; 17922 del; 5943 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8876.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8876/head:pull/8876

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