On Tue, 22 Oct 2024 14:18:33 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> 
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 seven additional commits 
>> since the last revision:
>> 
>>  - Add @since tag, respond to review feedback.
>>  - Merge branch 'master' into JDK-8341260
>>  - Remove comments for intrinsics per review feedback.
>>  - Update with changes from lworld+fp16 Float16.
>>  - Merge branch 'master' into JDK-8341260
>>  - Add support for BigDecimal -> Float16 conversion.
>>  - JDK-8341260: Add Float16 to jdk.incubator.vector
>
> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java line 
> 471:
> 
>> 469: //                     }
>> 470: //                 }
>> 471: //             }
> 
> Suggestion:
> 
>              int scale = bd.scale();
>              BigInteger unscaledValue = bd.unscaledValue();
> 
>              if 
> (unscaledValue.abs().compareTo(BigInteger.valueOf(Long.MAX_VALUE)) <= 0) {
>                  long intCompact = unscaledValue.longValue();
>                  Float16 v = Float16.valueOf(intCompact);
>                  if (scale == 0) {
>                      return v;
>                  }
>                  /*
>                   * The discussion for the double case also applies here. 
> That is,
>                   * the following test is precise for all long values, but 
> here
>                   * Long.MAX_VALUE is not an issue.
>                   */
>                  if (v.longValue() == intCompact) {
>                      if (0 < scale && scale < FLOAT16_10_POW.length) {
>                          return Float16.divide(v, FLOAT16_10_POW[scale]);
>                      }
>                      if (0 > scale && scale > -FLOAT16_10_POW.length) {
>                          return Float16.multiply(v, FLOAT16_10_POW[-scale]);
>                      }
>                  }
>              }

That does the trick; thanks for tracking down the mistake.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/21574#discussion_r1811306593

Reply via email to