bash "let" barfs on addition

Evuraan::ഏവൂരാന്‍ evuraan at gmail.com
Fri Mar 13 18:31:50 UTC 2009


Yes, I now see that bc gave the correct answer, as a signed int though:

$ printf "%u\n" -6246583658587674878
12200160415121876738

thank you all for the replies.!



2009/3/12 Evuraan::ഏവൂരാന്‍ <evuraan at gmail.com>:
> 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