On Thu, 18 Jul 2024 14:50:00 GMT, Raffaello Giulietti <rgiulie...@openjdk.org> 
wrote:

>> I mean only restricted to unsigned `long` perfect squares, something like 
>> the following, but written as a proper test
>> 
>> 
>>         long i = 0;
>>         for (; i < 1L << 32; ++i) {
>>             long x = i * i;
>>             long s = (long) Math.sqrt(x >= 0 ? x : x + 0x1p64);
>>             if (!(s + 1 == i || s == i)) {
>>                 System.out.format("oops... i=%d, but s=%d%n", i, s);
>>                 System.exit(1);
>>             }
>>         }
>
> It takes about 5 s on my laptop.

> I mean only restricted to unsigned `long` perfect squares, something like the 
> following, but written as a proper test
> 
> ```
>         long i = 0;
>         for (; i < 1L << 32; ++i) {
>             long x = i * i;
>             long s = (long) Math.sqrt(x >= 0 ? x : x + 0x1p64);
>             if (!(s + 1 == i || s == i)) {
>                 System.out.format("oops... i=%d, but s=%d%n", i, s);
>                 System.exit(1);
>             }
>         }
> ```

So, it is okay although the code does not test directly BigInteger.sqrt()?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19710#discussion_r1683009907

Reply via email to