[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Bug in gawk big num
From: |
Lưu Vĩnh Phúc |
Subject: |
[bug-gawk] Bug in gawk big num |
Date: |
Wed, 26 Sep 2018 12:41:53 +0700 |
Hello,
While checking this question on StackOverflow: HEX TO DEC conversion fail
for more than 16 digits <https://stackoverflow.com/a/52485753/995714> I
noticed that gawk often produces incorrect results
I've written a script to check gawk result compared with bc, my own
conversion script, perl and python. Without --bignum the output from gawk
is always incorrect in the last few digits. If the --bignum option is
included then it sometimes gives the correct output
For example
- 0x2111137875433111111DDDAFC = 9081107480899480908591836275756896935919
and gawk --bignum prints out 163738384160959209720665463548 but gawk prints
out 163738384160959190955653595136
- 0x361037073401E5313436BA5C23513A12311BDEF111DDDAFC
= 1325629231319468729194135471538271631225145170600986008316 but gawk
--bignum outputs 1325629231319468799563181404533249658969760453051956592640
and gawk outputs 1325629231319468625338609541012756365721961447986632327168
You can find my script to test and its result attached
My gawk version:
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 4.0.1, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2016 Free Software Foundation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
Kindly check it,
Thanks & Best regards,
*Luu Vinh Phuc*
Tel: (+84) 932 167 522 <address@hidden>
result.txt
Description: Text document
checkresult.sh
Description: Text Data
- [bug-gawk] Bug in gawk big num,
Lưu Vĩnh Phúc <=
Re: [bug-gawk] Bug in gawk big num, arnold, 2018/09/26
Re: [bug-gawk] Bug in gawk big num, arnold, 2018/09/27