bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] macOS: mpfrsqrt check fails on gawk-4.2-stable and master


From: Hermann Peifer
Subject: Re: [bug-gawk] macOS: mpfrsqrt check fails on gawk-4.2-stable and master branches
Date: Wed, 7 Feb 2018 22:01:35 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 07.02.18 21:16, Andrew J. Schorr wrote:
> On Wed, Feb 07, 2018 at 03:09:09PM -0500, Andrew J. Schorr wrote:
>> This looks like a precision problem. On Linux:
>>
>> bash-4.2$ echo 
>> 123456790123456790123456790123456790123456790123456790123454320987654320987654320987654320987654320987654320987654321
>>  1234567901234567901234567901234567901234567901234567901234 | ./gawk -M 
>> '{printf "%d\n", $1/$2}'
>> 99999999999999997168788049560464200849936328366177157906432
> 
> This is interesting:
> 
> bash-4.2$ echo 
> 123456790123456790123456790123456790123456790123456790123454320987654320987654320987654320987654320987654320987654321
>  1234567901234567901234567901234567901234567901234567901234 | ./gawk -M -l 
> extension/.libs/intdiv.so '{printf "%d\n", $1/$2; intdiv($1, $2, r); print 
> r["quotient"]}'
> 99999999999999997168788049560464200849936328366177157906432
> 100000000000000000000000000000000000000000000000000000000044
> 
> So the intdiv function seems to operate using higher precision. I imagine you 
> get
> the same answer for both on MacOS...
> 

Not really, see below. After adding PREC=400 on the command line, the
division result is correct, but not the result of intdiv().

Hermann

$ echo
123456790123456790123456790123456790123456790123456790123454320987654320987654320987654320987654320987654320987654321
1234567901234567901234567901234567901234567901234567901234 | ./gawk -M
-l extension/.libs/intdiv.so '{printf "%d\n", $1/$2; intdiv($1, $2, r);
print r["quotient"]}'
99999999999999997168788049560464200849936328366177157906432
99999999999999997168788049560464200849936328366177157906432
$
$ echo
123456790123456790123456790123456790123456790123456790123454320987654320987654320987654320987654320987654320987654321
1234567901234567901234567901234567901234567901234567901234 | ./gawk -M
-l extension/.libs/intdiv.so -vPREC=400 '{printf "%d\n", $1/$2;
intdiv($1, $2, r); print r["quotient"]}'
100000000000000000000000000000000000000000000000000000000044
99999999999999997168788049560464200849936328366177157906432




reply via email to

[Prev in Thread] Current Thread [Next in Thread]