Integrated: 8253409: Double-rounding possibility in float fma

Joe Darcy darcy at openjdk.java.net
Tue Feb 23 19:44:40 UTC 2021


On Tue, 23 Feb 2021 03:58:46 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.

This pull request has now been integrated.

Changeset: e5304b3a
Author:    Joe Darcy <darcy at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/e5304b3a
Stats:     32 lines in 2 files changed: 4 ins; 11 del; 17 mod

8253409: Double-rounding possibility in float fma

Reviewed-by: bpb

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

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


More information about the core-libs-dev mailing list