On Mon, Jul 11, 2022 at 10:14:12PM +0800, root@ROCKY8-5-WL.localdomain wrote: > [Detailed description of the problem, suggestion, or complaint.] > in bash the result of $[23**15] is wrong > for example output > [root@ROCKY8-5-02 ~]#echo $[23**15] > 8380818432457522983 > [root@ROCKY8-5-02 ~]#echo "23^15" | bc > 266635235464391245607
First of all, the $[ ] syntax has been deprecated for two decades. You should be using $(( )) instead. Second, you've overflowed the variable type that bash is using on your platform (most likely a 64-bit signed integer type). unicorn:~$ bc -l [...] 2^63 9223372036854775808 23^15 266635235464391245607 On almost all modern platforms, bash uses a 64-bit signed integer type for its arithmetic. The value you're trying to compute here is larger than that type can hold.