[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A BUG of 64-bit integer addition
From: |
PRC |
Subject: |
A BUG of 64-bit integer addition |
Date: |
Thu, 17 Apr 2008 11:21:58 +0800 |
Linux kernel is:
Linux version 2.6.16.1 (address@hidden) (gcc version 4.1.1 20060525 (Red Hat
4.1.1-1)) #1 SMP Thu Mar 22 09:22:29 CST 2007
And gawk version is:
GNU Awk 3.1.5
Copyright (C) 1989, 1991-2005 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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The test script is:
BEGIN {
a1 = 0x001ffffff0426d9b
b1 = 0x000000004392b6cc
c1 = a1+b1
a2 = 0xf0426d9b
b2 = 0x4392b6cc
c2 = a2+b2
printf("1 -- %16x + %16x = %16x\n", a1, b1, c1);
printf("2 -- %16x + %16x = %16x\n", a2, b2, c2);
}
The results of runing this script are:
1 -- 1ffffff0426d9b + 4392b6cc = 20000033d52468
2 -- f0426d9b + 4392b6cc = 133d52467
The first calculation is wrong.
Best Regards,
PRC
Apr 17, 2008