finds.dev← search

// the find

PaulRBerg/prb-math

★ 1,001 · Solidity · MIT · updated Jun 2026

Solidity library for advanced fixed-point math

PRBMath is a fixed-point math library for Solidity, providing signed (SD59x18) and unsigned (UD60x18) 18-decimal arithmetic with transcendental functions — logs, exponentials, powers, square roots. It's for DeFi protocol developers who need math that goes beyond basic arithmetic and want type-safe wrappers instead of raw uint256 juggling.

User-defined value types mean you can't accidentally pass a raw uint256 where a fixed-point number is expected — the compiler catches it. The `mulDiv` implementation handles intermediary overflow correctly for 256-bit numbers, which is the thing that actually bites people writing this themselves. Gas numbers are published with honest comparisons against ABDKMath, including the cases where PRBMath loses. The test suite uses both unit tests and fuzz tests via Foundry, with `.tree` files that document the expected branching behavior for each function.

The adjacent types (SD1x18, UD2x18, etc.) have no math functions — you have to unwrap, cast to the full type, do math, cast back, which mostly defeats the purpose of having them as value types. Mul and div are noticeably slower than ABDKMath due to 256-bit intermediary overflow handling; in a hot path this adds up. The library requires Solidity 0.8.19+ specifically, not just 0.8.x — there's a compiler version floor that's easy to miss and will give you cryptic errors. Gas report generation is acknowledged as unsolved in a GitHub discussion, so the published numbers are from specific historical releases and may not reflect the current version.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →