Skip to content

Instantly share code, notes, and snippets.

@samlaf
Created January 18, 2022 22:44
Show Gist options
  • Save samlaf/1891a561ac49dadd7455c96d08117903 to your computer and use it in GitHub Desktop.
Save samlaf/1891a561ac49dadd7455c96d08117903 to your computer and use it in GitHub Desktop.
Solidity Weirdness
function test(uint256 a) public pure returns (uint256) {
uint256 fooERROR = 2 * 997 / 1000; // ERROR: Type rational_const 997 / 500 is not implicitly convertible to expected type uint256. Try converting to type ufixed16x3 or use an explicit conversion.
uint256 fooOK = a * 997 / 1000; // this works... somehow
uint256 fooERROR2 = a * (997 / 1000); // Operator * not compatible with types uint256 and rational_const 997 / 1000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment