Skip to content

Division Before Multiplication Precision Loss

SAFE-0017 Arithmetic Checked automatically by the scanner
1

What goes wrong

Integer division truncates. Dividing before multiplying discards the remainder and produces a materially smaller (or zero) result, letting users underpay or starving reward accounting.

2

How to fix it

the pattern that is safe
uint256 reward = (amount * rewardPool) / totalStaked;  // multiply first
Multiply-before-divide; scale with a precision factor.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0017 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs