n...@lavabit.com wrote:
>         echo $((256**8))
>         echo $((72057594037927936*128))
>         echo $((1000000000000000000000000))
>         etc.

Unless great effort is made to perform math in arbitrary precision

  http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic

all computer arithmetic is done using native machine integers.  As
documented in the bash manual in the ARITHMETIC EVALUATION section:

  ARITHMETIC EVALUATION
       Evaluation is done in fixed-width integers with no check for
       overflow, though division by 0 is trapped and flagged as an
       error.

Your expressions above are overflowing the value of your system's
maximum integer size.  You can read the system's maximum integer size
using getconf.

  $ getconf INT_MAX
  2147483647

Fixed integer calculations are native to the system hardware and very
fast and most of the time sufficient for most tasks.

If you need larger numbers then you would need to use a tool that
supports arbitrary precision arithmetic such as 'bc'.  The bc tool may
be called from the shell to perform your calculations.  It is a
powerful calculator.

  $ man bc

  $ echo $(echo "72057594037927936*128" | bc -l)
  9223372036854775808

Bob

Reply via email to