RFR: JDK-8302040: Port fdlibm sqrt to Java

Raffaello Giulietti rgiulietti at openjdk.org
Fri Feb 24 13:39:21 UTC 2023


On Thu, 23 Feb 2023 23:39:26 GMT, Joe Darcy <darcy at openjdk.org> wrote:

>> The wheel of FDLIBM porting turns a notch and sqrt comes into play.
>> 
>> While the sqrt operation usually has a hardware implementation that is intrinsified, for completeness a software implementation should be available as well.
>
> src/java.base/share/classes/java/lang/FdLibm.java line 689:
> 
>> 687:             ix0 += (m << 20);
>> 688:             z = __HI(z, ix0);
>> 689:             z = __LO(z, ix1);
> 
> I was tempted to rewrite these line as something like:
> `return Double.longBitsToDouble((long)ix0 << 32 | (long)ix1);`
> and may do so in a future refactoring.

That should read
`return Double.longBitsToDouble((long)ix0 << 32 | ix1 & 0xffff_ffffL);`

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

PR: https://git.openjdk.org/jdk/pull/12736


More information about the core-libs-dev mailing list