Consider the following simple contract:
pragma solidity ^0.4.16;
contract TestContract {
function add(uint256 amount) returns (uint256) {
require(amount > 0);
return 100 + amount;
}
}
I would expect that the result of this function is always greater than 100. Except for an uint overflow scenario, but let's not discuss that.
If i call the function from geth like this the result is like expected 105.
> testInstance.add.call(5)
If i call the function with an negative number, i would expect that an exception is thrown or that the input is changed to zero and the result is 100, but instead in returns 95.
> testInstance.add.call(-5)
So how is that possible? Has anyone an idea? Is it just bad practice to pass negative numbers to the function?