bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] How does awk implement extremely long integers?


From: Peng Yu
Subject: [bug-gawk] How does awk implement extremely long integers?
Date: Tue, 31 Jan 2012 09:03:05 -0600

Hi,

I don't see where the limit of an integer in gawk is documented. But I
tried the following code on my MacBook Pro (64bit) with macports
installation. It can store integer as large as 2^1023. (I suspect the
maximum should be something like 2^1024-1, but I never test it). I'm
wondering how gawk store and compute some big integer, as an integer
of this large is beyond any native type supported my the machine.

If some library is used to support long integers, why not use one that
supports infinitely large integer?

~$ seq 1023|awk 'BEGIN{i=1}{i*=2}END{print i}'
89884656743115795386465259539451236680898848947115328636715040578866337902750481566354238661203768010560056939935696678829394884407208311246423715319737062188883946712432742638151109800623047059726541476042502884419075341171231440736956555270413618581675255342293149119973622969239858152417678164812112068608

~$ seq 1024|awk 'BEGIN{i=1}{i*=2}END{print i+2}'
inf

-- 
Regards,
Peng



reply via email to

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