The ladder is the argument: precision over N steps, which is how protocols use a math library. This page is the per-op view behind it, measured by the same Foundry suites that CI runs on every commit.
Gas per op
| op | Yul object (staticcall) | FP127Lib (inline) | ABDKMath64x64 | Solady | PRBMath SD59x18 |
|---|---|---|---|---|---|
| abs | 706 | 612 | 526 | — | 551 |
| add | 1303 | 281 | 575 | 490 | 473 |
| avg | 1632 | 501 | 466 | — | 426 |
| cbrt | 6163 | 6792 | — | 836 | — |
| ceil | 858 | 658 | — | — | 613 |
| dist | 976 | 736 | — | — | — |
| div | 1401 | 939 | 578 | 361 | 715 |
| exp | 5261 | 5353 | 3512 | 549 | 2898 |
| exp10 | 4858 | 5689 | — | — | — |
| exp2 | 5116 | 5173 | 2922 | — | 609 |
| factorial | 1581 | 1290 | — | — | — |
| floor | 1401 | 583 | — | — | 620 |
| frac | 1266 | 601 | — | — | 544 |
| fromFixed18 | 1223 | 778 | — | — | — |
| gavg | 4161 | 3846 | 1288 | — | 1267 |
| gcd | 1209 | 753 | — | — | — |
| hypot | 4684 | 4175 | — | — | — |
| inv | 1295 | 1078 | 480 | 337 | 487 |
| lambertW0 | 36086 | 45497 | — | 2937 | — |
| lambertWm1 | 29159 | 35588 | — | — | — |
| ln | 1696 | 999 | 7325 | 720 | 1052 |
| log10 | 1943 | 1042 | — | — | 2640 |
| log2 | 1970 | 832 | 7232 | — | 744 |
| log2Up | 1648 | 755 | — | — | — |
| max | 1197 | 515 | — | — | — |
| min | 925 | 493 | — | — | — |
| mul | 1569 | 472 | 480 | 347 | 647 |
| neg | 869 | 604 | 487 | — | — |
| pi | 5364 | 5987 | — | — | — |
| pow | 5803 | 6408 | 1892 | 1618 | 9980 |
| round | 980 | 761 | — | — | — |
| sign | 1275 | 576 | — | — | 587 |
| sqrt | 3753 | 3564 | 1111 | 622 | 1333 |
| sub | 1340 | 319 | 587 | 500 | 482 |
| toFixed18 | 1269 | 790 | — | — | — |
| zeroFloorSub | 1751 | 683 | — | — | — |
Median gas per op over its input ladder, 2026-10-06. The Yul object column includes the staticcall; the other four are internal library calls. A dash is an op the library does not offer, or that reverted on every ladder input. Min and max per cell are in gas.json; the Huff and FP127Caller columns are in gas.md. Versions: abdk v3.2, forge forge Version: 1.7.1, fp127 a7bbe32, huff sepolia:0xfae694D0c2c44181791F838c54Ed64C3151FfE30@11857616, prb-math v4.2.0, solady v0.1.26.
Multiplication and division cost about what they cost in WAD. The transcendentals cost more because they compute twice as many bits.
Precision per op
| op | vectors | reverts | min bits | mean bits | worst input |
|---|---|---|---|---|---|
| abs | 96 | 1 | exact | exact | |
| add | 381 | 19 | exact | exact | |
| avg | 200 | 0 | exact | exact | |
| cbrt | 96 | 1 | 123 | 152 | 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff |
| ceil | 95 | 2 | exact | exact | |
| clamp | 300 | 0 | exact | exact | |
| dist | 190 | 10 | exact | exact | |
| div | 377 | 23 | exact | exact | |
| exp | 87 | 4 | 146 | 221 | 0x0000000000000000000000000000001400000000000000000000000000000000 |
| exp10 | 66 | 3 | 146 | 211 | 0x0000000000000000000000000000000a00000000000000000000000000000000 |
| exp2 | 80 | 3 | 146 | 211 | 0x0000000000000000000000000000003200000000000000000000000000000000 |
| factorial | 12 | 6 | exact | exact | |
| floor | 97 | 0 | exact | exact | |
| frac | 97 | 0 | exact | exact | |
| fromFixed18 | 33 | 4 | exact | exact | |
| gavg | 166 | 34 | exact | exact | |
| gcd | 81 | 0 | exact | exact | |
| hypot | 121 | 0 | exact | exact | |
| inv | 62 | 3 | exact | exact | |
| lambertW0 | 108 | 3 | 65 | 249 | 0xffffffffffffffffffffffffffffffffa1d2a7274c4320e54521387d6fab06f4 |
| lambertWm1 | 66 | 6 | 67 | 243 | 0xffffffffffffffffffffffffffffffffa1d2a7274c4320e54521387d6fab06f3 |
| lerp | 289 | 11 | exact | exact | |
| ln | 299 | 4 | 255 | 255 | 0x0000000000000000000000000000000000000000000000000000000000000001 |
| log10 | 299 | 4 | 255 | 255 | 0x0000000000000000000000000000000000000000000000000000000000000003 |
| log2 | 299 | 4 | 255 | 255 | 0x00000000000000000000000000000000ffbe76c8b4395810624dd2f1a9fbe76c |
| log2Up | 299 | 4 | exact | exact | |
| max | 200 | 0 | exact | exact | |
| min | 200 | 0 | exact | exact | |
| mul | 224 | 176 | exact | exact | |
| neg | 96 | 1 | exact | exact | |
| pi | 8 | 7 | 122 | 139 | 0x0000000000000000000000000000000300000000000000000000000000000000 |
| pow | 369 | 31 | 122 | 226 | 0x00000000000000000000000000000001028f5c28f5c28f5c28f5c28f5c28f5c2,0x0000000000000000000000000000016d00000000000000000000000000000000 |
| round | 95 | 2 | exact | exact | |
| sign | 97 | 0 | exact | exact | |
| sqrt | 298 | 3 | exact | exact | |
| sub | 387 | 13 | exact | exact | |
| toFixed18 | 97 | 0 | exact | exact | |
| zeroFloorSub | 189 | 11 | exact | exact |
Relative correct bits of the 127.128 result, msb(|truth|) − msb(|truth − got|), against mpmath at 200 decimal places over the committed vectors in test/fp127/vectors/. "exact" is bit-identical, or within 2 ULP for an approximated op. Reverts counts vectors where the oracle and the Yul both reject the input with the same error. Source: precision.json.
Integer, rounding and comparison ops are bit-exact, and so are ln, log2 and log10 to within one ULP of the truth; exp, exp2 and exp10 hold 146 bits or better, the limit of their degree-24 polynomial. The transcendentals compute with 64 guard bits and round to nearest once, so their error has no sign bias and iterated calls do not drift. The two Lambert W branches lose bits only within 2^-20 of the branch point at −1/e, where the slope is infinite and one ULP of input moves the output by 2^-63; everywhere else they measure 126 to 128 bits.