bash "let" barfs on addition

Evuraan::ഏവൂരാന്‍ evuraan at gmail.com
Thu Mar 12 18:57:12 UTC 2009


Greetings y'all..!

Seen this sort of behaviour before? :

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

The correct answer should have been: 12200160415121876738

mybash:> echo "$a+$b" |bc -l
12200160415121876738


mybash:> bash --version
GNU bash, version 3.2.25(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
mybash:>

I know, I can use bc,dc,awk, python and even a desk calculator  wide
enough :) - but, I am curious as to why is "let" letting us down?

Does a known bug exist already?

Any input would be much appreciated, many thanks in advance.!




More information about the ubuntu-users mailing list