2

so lets say result of a calculation in solidity is 0.2 or 0.8, when I save that result in a variable does that convert to 0 or 1 ?

3

Solidity truncates all results, it's equivalent to the floor operation. So if your contract tries to store the result of 9 / 5 in a uint it will simply store 1

| improve this answer | |
  • For stake of completeness: are negative numbers floored as well, or are they rounded towards zero? – jjj Nov 8 at 19:27
  • Negative numbers are rounded up towards zero: -4 / 3 => -1 – MrClottom Nov 8 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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