Very strangely, I found that in awk, the big integer looks like has only 53 bits.Here is my example:
function bits2str(bits,data, mask)
{
if (bits == 0)
return "0"
mask = 1
for (; bits != 0; bits = rshift(bits, 1))
data = (and(bits, mask) ? "1" : "0") data
while ((length(data) % 8) != 0)
data = "0" data
return data
}
BEGIN{
print 32,"\tlshift 48:\t", lshift(32,48), "\t", bits2str(lshift(32,48))
print 429,"\tlshift 48:\t", lshift(429,48), "\t", bits2str(lshift(429,48))
}
and the output is:
32 lshift 48: 0 0
429 lshift 48: 3659174697238528 00001101000000000000000000000000000000000000000000000000
but in c++, its output is:
32 lshift 48: 9007199254740992
429 lshift 48: 120752765008871424
After comparing the two output, I found that the awk's only have 53 bits, and then I researched the source code of gawk(start from line 3021 in the file named builtin.c, gawk 4.1.1, http://ftp.gnu.org/gnu/gawk/), but I found no special operation on int. So, what causes this? Why it is like this?