According to readthedocs.io:

"Division on integer literals used to truncate in earlier versions, but it will now convert into a rational number, i.e. 5 / 2 is not equal to 2, but to 2.5".

Yet, when I try simple math problems like this on Remix, they are truncated.
So, "5 / 2" still equals 2, and I have to use "%" or "remainder = _dividend - (quotient * _divisor)" to produce the remainder separately.

I believe I am using the latest compiler version "0.4.24". So is the information from readthedocs just wrong? Or does it means something else?


1 Answer 1


I believe what that note is saying is that this function:

function test() public pure returns (uint256) {
    return (5 / 2) * 10;

used to return 20 but now returns 25.

There are no fixed-point/floating-point numbers in Solidity, so you can't return a number like 2.5, but you can use one up until the point where you try to store it in an integer.

  • Ah yes, it is 2; typo. I edited it. Jun 8, 2018 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.