bash "let" barfs on addition

Cameron Hutchison lists at xdna.net
Thu Mar 12 22:07:13 UTC 2009


=?UTF-8?B?RXZ1cmFhbjo64LSP4LS14LWC4LSw4LS+4LSo4LWN4oCNIA==?= <evuraan at gmail.com> writes:

>Seen this sort of behaviour before? :

>mybash:>  a="7540113804746346429"
>mybash:>  b="4660046610375530309"
>mybash:> let c=(a+b)
>mybash:> echo $c
>-6246583658587674878

Both a and b are 63-bit numbers. It looks like bash is using signed
64-bit numbers for its arithmetic, as your arithmetic will overflow when
performed with signed 64-bit numbers.





More information about the ubuntu-users mailing list