develooper Front page | perl.perl5.porters | Postings from June 2021

Re: quadmath with 32 bit ints

Thread Previous | Thread Next
Peter John Acklam
June 29, 2021 16:48
Re: quadmath with 32 bit ints
Message ID:
An update …

I modified the logic so it can handle the case with ivsize = 4 and
nvsize = 16. However, it broke Math::BigInt::FastCalc, which uses the
same base length as Math::BigInt::Calc. There is something in the XS
code that causes Math::BigInt::FastCalc to fail when the base length
is larger than 15. I don't know what causes the problem. To make
things worse, a base length of 15 doesn't work on systems with ivsize
= 4. It would work on systems with ivsize = 4 if it hadn't been for
the _is_even() and _is_odd() methods. They convert the NV to a UV and
do a bitwise "… & 1" to determine if a number is odd or even.
Consequently, we can't use NVs that are too large to fit inside a UV.

I believe it would be hardly noticeable if I scrapped the _is_even()
and _is_odd() in Math::BigInt::FastCalc. If I did, then
Math::BigInt::FastCalc would work with a base length of 15 also when
the ivsize = 4, but I don't know how much there is to gain from
increasing the base length from 9 to 15. I haven't timed it.

When that was working, I thought it would be useful to be able to
specify the base length manually. There is an RT with a wish for this
functionality. It turned out to be a lot more work then I expected,
because Math::BigInt::Calc makes a lot of assumptions on the minimum
base length. After some work, I got it working, so with my development
version of Math::BigInt, I can explicitly set the base length to 3

    use Math::BigInt::Calc base_len => 3;
    use Math::BigInt lib => "Calc";

Hopefully, I will be able to release something in the not too distant future.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About