17
5
I'm curious as to what happens when a numeric variable in bash is incremented up without purposely stopping it. How large can the number get? Will it overflow and become negative and just continue to increment forever? Will it break and skid to a stop at some point?
I am using an x86_64 AMD processor, but I would be happy to hear 32bit answers as well, just specify which you are talking about. I am running Fedora21 64bit.
I've googled far and wide but haven't found this specific tidbit for some odd reason. It seems like it would be a basic piece of info in all the manuals and such.
3How about printing out some powers of 2 as a starter:
for i in {0..70}; do echo 2 to the power of $i = $((2**i)); done
– mpy – 2016-01-22T21:19:46.8031If you want big numbers, you might switch to
ksh
which does floating point arithmetics, not integer one likebash
:ksh -c 'echo $((2**1023))'
→8.98846567431157954e+307
– jlliagre – 2016-01-22T21:36:53.377I will keep ksh in mind if I need floating point or values in the stratosphere, floating point can be quite useful. But this question is simply so that I know the limits of my system, it is not because I need to exceed its limits. I will do something like mpy suggests, I didn't to start with because I didn't want risk causing a system crash. – Max Power – 2016-01-23T00:27:48.863