bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Bug in gawk big num


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Bug in gawk big num
Date: Wed, 26 Sep 2018 08:41:55 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Sep 26, 2018 at 12:41:53PM +0700, Lưu Vĩnh Phúc wrote:
> You can find my script to test and its result attached

One quick comment about this: the problem here seems to be in the strtonum
function. If you modify checkresult.sh like so:

--- checkresult.sh      2018-09-26 08:32:16.469895260 -0400
+++ cr.sh       2018-09-26 08:34:27.506910803 -0400
@@ -105,8 +105,8 @@ while read -r v; do
     hex2dec_res=$(hex2dec $v)
     perl_res=$(perl -Mbignum -le "print hex '$v'")
     python_res=$(python -c "print int('$v', 16)")
-    gawkbignum_res=$(gawk --bignum -v n=0x$v 'BEGIN {print strtonum(n)}')
-    gawk_res=$(gawk -v n=0x$v 'BEGIN {print strtonum(n)}')
+    gawkbignum_res=$(gawk --bignum "BEGIN {print 0x$v+0}")
+    gawk_res=$(gawk "BEGIN {print 0x$v+0}")
     
     echo -ne "\n----------- $v:"
     echo -ne "\n            bc: $bc_res"

Then all of the gawk --bignum errors will disappear (but the plain
gawk_res values do not change).

So this leaves the question of why strtonum does not work as expected.
I guess there may be a bug in mpfr.c:do_mpfr_strtonum, but don't have time
to dig deeper right now...

Regards,
Andy



reply via email to

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