[geeks] expr and math

Scott Howard scott at doc.net.au
Tue Sep 21 06:01:34 CDT 2004


On Tue, Sep 21, 2004 at 04:00:48AM -0500, Brian Dunbar wrote:
> briandunbar_natasha_~:expr 90 \* 100000000
> 410065408

expr generally works on "integers" as defined by the system. ie, once you
hit MAX_INT weird stuff will happen.

If you want unlimited precision math, use bc

$ echo 90 \* 1000000000 | bc
90000000000
$ echo 90 \* 100000000000000000000000000 | bc
9000000000000000000000000000
$ echo 90 \* 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | bc
90000000000000000000000000000000000000000000000000000000000000000000\
0000000000000000000000000000000000000000000000000000000000000000

  Scott.



More information about the geeks mailing list