bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] awk integer math.


From: Mark Cross
Subject: [bug-gawk] awk integer math.
Date: Tue, 16 Sep 2014 03:48:12 -0400

awk fails to correctly calculate 6^36 (or equivalent 6**36).


execute                          -->  gawk 'BEGIN{print 6^36}'
get                                 -->  10314424798490536576964100096
code for expected value   -->  export BC_LINE_LENGTH=0; echo "6^36"| bc -l
expected correct value     -->  10314424798490535546171949056
diff                                  -->  00000000000000001030792151040

Using this version: gawk -V     GNU Awk 4.0.1


of course, with 6^216 the error is even worse.


gawk 'BEGIN{print 6^216}'
1204120867648235164486943491440928837580490935108600474086790649405798652603116653039160022270195825661497785157692584212248992120513865097754834507781402676223732088832
export BC_LINE_LENGTH=0; echo "6^216"| bc -l
1204120867648235108202090056857283403336732693457453224358121221145020555710636789704085475234591191603986789604949502079328192358826561895781636115334656050057189523456

diff= 
56284853434583645434243758241651147249728669428260778096892479863335074547035604634057510995552743082132920799761687303201973198392446746626166542565376

Best regards.
MC

reply via email to

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