In cmd there is a restriction on storing an integer type, it does not seem to exceed 2 ^ 16, but what happens if there is such a cycle: for ((a = 1; a <= $ amount; a ++)) and the amount exceeds allowable size?
2 answers
the maximum integer with which bash is capable of computing, theoretically, can vary depending on the implementation of this program, and the operating system used, and the processor architecture.
in the implementation of bash for the gnu operating system , which is most often found, the maximum integer is 2 in the 63rd degree minus 1:
$ ((x=2**63-1)); echo $x 9223372036854775807
if we add one to this number, then, due to the arithmetic overflow, we get a negative number:
$ ((x=2**63-1)); echo $((x+1)) -9223372036854775808
about the same comparison: if in the expression (an analogue of yours)
$ test $x -le $amount
in the $amount
variable there will be a string that bash cannot convert to an integer (for example, 2 to the 63rd power), then when executed we will get an error:
$ test $x -le 9223372036854775808 bash: test: 9223372036854775808: integer expression expected
Integer - 32 bits on the command line. Throws out a message that you have entered a greater number than is laid down in the type of variable a. Before compiling the program.
- Compiling? And isn’t there an interpretation? - LEQADA