Some initial thoughts for putting PRBMath to use:
Utilize the unsigned type assuming you are working with non-negative numbers (slightly more gas efficient too!)
Utilize mul/div functions to preserve precision and avoid overflow
Perform fixed point conversions once at the start/end to reduce recompilationrecomputation and scaling errors
Include base case/early conditional returns to short-circuit cheap paths
Note that PRBMath works with user defined types
You can utilize unwrap to get the underlying primitive and ud to wrap into the defined type.
function log10From1e8 (uint256 usd) external returns (uint256){ uint256 x = usd * 1e10; // 1e8 -> 1e18 return unwrap(ud(x).log10()); } As an alternative to PRBMath, you can also check out Solady. The library contains a number of gas optimized utilities and had an audit completed by Spearbit (sponsored by Base) in March 2025.