Add comment on unchecked arithmetic (division by zero) in Math.sol (#4050)
Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
committed by
GitHub
parent
8a43ebac28
commit
eb38c059d8
@ -67,6 +67,9 @@ library Math {
|
|||||||
|
|
||||||
// Handle non-overflow cases, 256 by 256 division.
|
// Handle non-overflow cases, 256 by 256 division.
|
||||||
if (prod1 == 0) {
|
if (prod1 == 0) {
|
||||||
|
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
|
||||||
|
// The surrounding unchecked block does not change this fact.
|
||||||
|
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
|
||||||
return prod0 / denominator;
|
return prod0 / denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user