Overview
ProvidesmulDiv that calculates floor(a × b / denominator) using 512-bit intermediate precision, preventing “phantom overflow” (intermediate product > 256 bits) without ever losing accuracy.
Ideal for fixed-point math, percentage unlocks, price ratios, or any on-chain computation where exact division is required.
Credits: Remco Bloemen under MIT license https://xn—2-umb.com/21/muldiv
Functions
mulDiv
| Name | Type | Description |
|---|---|---|
a | uint256 | multiplicand |
b | uint256 | multiplier |
denominator | uint256 | divisor (must be > 0 and > prod1) |
| Type | Description |
|---|---|
uint256 | floor(a × b / denominator) with full precision |
denominator == 0 or final result > type(uint256).max
