What happens in arithmetically overcrowded?



  • In cmd there's a restriction on the storage of a whole type, it's probably not more than 216, but what happens if there's a cycle like this: for ((a=1; a convoy=$amount ; a+++) and the amount exceeds the allowable amount?



  • with which programme bash is capable of computing, theoretically, may vary depending on the programme ' s implementation, the operational system used, and the processor architecture.

    Total https://www.gnu.org/software/bash/ which is most likely to be met, the maximum is 2 to 63 degrees minus 1:

    $ ((x=2**63-1)); echo $x
    9223372036854775807
    

    If a unit is added to this number, the arithmetic overcrowding will result in a negative number:

    $ ((x=2**63-1)); echo $((x+1))
    -9223372036854775808
    

    Comparison: If in terms (the same as yours)

    $ test $x -le $amount
    

    variable $amount There'll be a line bash It will not be possible to transform into a whole (e.g., 2 to 63), if we fail:

    $ test $x -le 9223372036854775808
    bash: test: 9223372036854775808: integer expression expected
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2