I noticed that the following Solidity functions are not equivalent:
function a(int256 x) pure returns (uint256 result) {
assembly {
result := div(sub(0, x), x)
}
}
function b(int256 x) pure returns (uint256 result) {
result = -x / x;
}
If we pass 8 as an input, we get two different results back:
a: 14474011154664524427946373126085988481658748083205070504932198000989141204991
b: -1
What gives? I would have expected the results to be the same.