Why does we still need StrictMath?

Andrew Haley aph-open at littlepinkcloud.com
Sun May 8 08:56:07 UTC 2022


On 5/8/22 06:54, Victor Williams Stafusa da Silva wrote:
> If StrictMath is still needed and could produce different results than
> Math in some modern hardware, then by the javadocs, it seems to imply that
> Math should always delegate to StrictMath and never the other way around.
> Why is it not always the case? I think that the answer is simply because
> the StrictMath class was largely left unchanged and that delegating in one
> way or in the other could then produce a difference when the strictfp
> modifier was there, but is there a better reason than that?

Some targets (x86, in particular) have intrinsics (log, trig) that
are faster than StrictMath and also more accurate. StrictMath is not
about accuracy, but cross-architecture down-to-the-last bit reproducibility.
Whether we still need that reproducibility is, I suppose, something for
debate.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671


More information about the core-libs-dev mailing list