Skip to main content

Rounding Errors

What it detects

This detector finds integer division or modulo operations where the remainder is silently truncated. Contracts that expect fractional values can misbehave when precision is lost.

Typical symptoms

  • Calculations yield smaller results than expected
  • Percentage math using integers looks off

Solidity snippet (v0.8.25)

pragma solidity ^0.8.25;

contract RoundingDemo {
function divide(uint256 a, uint256 b) external pure returns (uint256) {
// Precision loss if 'b' doesn’t divide 'a' exactly
return a / b;
}
}

Why it matters on EVM

Rounding errors accumulate over time, leading to financial discrepancies or drained reserves in DeFi protocols.