Explain the Difference between an Overflow and an Underflow.

An overflow occurs when the result of an arithmetic operation, typically addition or multiplication, is larger than the maximum value that the data type can hold. For instance, if a variable can hold up to 255, and you add 1 to 255, it overflows and wraps to 0.

An underflow occurs when the result of a subtraction is smaller than the minimum value the data type can hold, which is typically zero for unsigned integers. Subtracting 1 from 0 causes an underflow and wraps to the maximum value.

What Is the Maximum Value of a Uint256 in Solidity?
Should the Limit Price Be Set above or below the Stop Price for a Sell Order?
What Tools Are Used to Detect Integer Overflow and Underflow Vulnerabilities?
How Does the TOTAL2 Index (Total Crypto Market Cap Excluding BTC) Correlate with Bitcoin Dominance?
What Is the Safe Math Library and Why Is It Used?
How Did the DAO Hack Relate to Integer Overflow?
How Does the Block Limit Influence the Maximum Number of Transactions per Block?
Can an Attacker Cause Both an Overflow and an Underflow in a Single Transaction?

Glossar