programming:bash:overflow
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
programming:bash:overflow [2022/03/31 07:15] – Adding explanations ateixeira | programming:bash:overflow [2022/03/31 07:31] – ateixeira | ||
---|---|---|---|
Line 4: | Line 4: | ||
It will depend on your version of bash, your OS((Operating System)) and your CPU((Processor)) architecture. To try it, we will set a variable to (2^16). If the output is the right answer, we will set it to (2^32), and so on untill the answer is not right anymore. | It will depend on your version of bash, your OS((Operating System)) and your CPU((Processor)) architecture. To try it, we will set a variable to (2^16). If the output is the right answer, we will set it to (2^32), and so on untill the answer is not right anymore. | ||
- | In the example below, we can see that at (2^64) the answer is not right anymore. So we substract 1 at the result | + | In the example below, we can see that at (2^64) the answer is not right anymore. So we substract 1 at the result |
Then we substract 1 at the result | Then we substract 1 at the result | ||
Line 31: | Line 31: | ||
| | ||
| | ||
- | Output will be: | + | ==== Output will be : ==== |
65536 | 65536 | ||
Line 48: | Line 48: | ||
9223372036854775908 | 9223372036854775908 | ||
-9223372036854775707 | -9223372036854775707 | ||
+ | |||
+ | |||
+ | ==== Interesting fact : ==== | ||
+ | |||
+ | > At the end, we set a variable bigger than the MAX limit and increment 1. The variable is at first stocked as a STR but when we force it to increment 1, we see that bash will compensate and output the MIN limit incremented by 1. | ||
programming/bash/overflow.txt · Last modified: 2022/03/31 15:07 by ateixeira