RFR: 8253409: Double-rounding possibility in float fma [v2]
Brian Burkhalter
bpb at openjdk.java.net
Tue Feb 23 19:13:40 UTC 2021
On Tue, 23 Feb 2021 07:00:07 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>> In floating-point, usually doing an operation to double precision and then rounding to float gives the right result in float precision. One exception to this is fused multiply add (fma) where "a * b + c" is computed with a single rounding. This requires the equivalent of extra intermediate precision inside the operation. If a float fma is implemented using a double fma rounded to float, for some well-chosen arguments where the final result is near a half-way result in *float*, an incorrect answer will be computed due to double rounding. In more detail, the double result will round up and then the cast to float will round up again whereas a single rounding of the exact answer to float would only round-up once.
>>
>> The new float fma implementation does the exact arithmetic using BigDecimal where possible, with guard to handle the non-finite and signed zero IEEE 754 details.
>
> Joe Darcy has updated the pull request incrementally with one additional commit since the last revision:
>
> Add a jtreg run command to disable any fma instrinic so the Java code is tested.
Looks fine. Presumably the updated test fails without the source change.
-------------
Marked as reviewed by bpb (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/2684
More information about the core-libs-dev
mailing list