Per op
Gas and single-call precision for FP127 against ABDK, Quad, Solady, PRBMath and Balancer.
Gas per op
| op | Yul object (staticcall) | FP127Lib (inline) | ABDKMath64x64 | Solady | PRBMath SD59x18 | ABDKMathQuad | Balancer LogExpMath |
|---|---|---|---|---|---|---|---|
| abs | 745 | 708 | 594 | — | 643 | 588 | — |
| add | 1459 | 289 | 587 | 502 | 506 | 1252 | — |
| atanh | 8701 | 9846 | — | — | — | — | — |
| avg | 1895 | 581 | 497 | — | 416 | — | — |
| cbrt | 6719 | 7263 | — | 859 | — | — | 2457 |
| ceil | 896 | 742 | — | — | 700 | — | — |
| compound | 5366 | 4573 | — | — | — | — | — |
| cosh | 9217 | 11389 | — | — | — | — | — |
| dist | 1017 | 855 | — | — | — | — | — |
| div | 1438 | 981 | 546 | 329 | 705 | 1209 | 512 |
| erf | 20201 | 23274 | — | — | — | — | — |
| erfc | 20556 | 23278 | — | — | — | — | — |
| exp | 5532 | 5366 | 3542 | 547 | 2951 | 6072 | 1191 |
| exp10 | 4886 | 5734 | — | — | — | — | — |
| exp2 | 5360 | 5201 | 2985 | — | 638 | 4534 | — |
| expm1 | 6995 | 8018 | — | — | — | — | — |
| factorial | 1594 | 1381 | — | — | — | — | — |
| floor | 1650 | 667 | — | — | 708 | — | — |
| frac | 1481 | 722 | — | — | 612 | — | — |
| fromFixed18 | 1376 | 1060 | — | — | — | — | — |
| gavg | 4297 | 3928 | 1319 | — | 1254 | — | — |
| gcd | 1301 | 887 | — | — | — | — | — |
| hypot | 4918 | 4260 | — | — | — | — | — |
| inv | 1335 | 1121 | 532 | 332 | 554 | 1675 | — |
| lambertW0 | 36239 | 45658 | — | 2937 | — | — | — |
| lambertWm1 | 29362 | 35715 | — | — | — | — | — |
| ln | 1807 | 1035 | 7340 | 731 | 1099 | 1927 | 1358 |
| log10 | 2149 | 1085 | — | — | 2712 | — | — |
| log1p | 4714 | 5453 | — | — | — | — | — |
| log2 | 2218 | 897 | 7276 | — | 828 | 1235 | — |
| log2Up | 1768 | 843 | — | — | — | — | — |
| max | 1306 | 554 | — | — | — | — | — |
| min | 965 | 536 | — | — | — | — | — |
| mul | 1799 | 531 | 455 | 321 | 641 | 1036 | 471 |
| neg | 891 | 694 | 559 | — | — | 585 | — |
| normCdf | 20389 | 23487 | — | — | — | — | — |
| pi | 5480 | 6065 | — | — | — | — | — |
| pow | 6094 | 6654 | 1932 | 1605 | 10062 | 23879 | 2412 |
| powu | 5030 | 3263 | — | — | — | — | — |
| round | 1020 | 840 | — | — | — | — | — |
| sign | 1480 | 660 | — | — | 676 | — | — |
| sinh | 5780 | 6919 | — | — | — | — | — |
| sqrt | 3799 | 3632 | 1159 | 622 | 1402 | 1205 | 2520 |
| sub | 1543 | 348 | 626 | 539 | 544 | 1768 | — |
| tanh | 7452 | 8909 | — | — | — | — | — |
| toFixed18 | 1421 | 1073 | — | — | — | — | — |
| zeroFloorSub | 2023 | 806 | — | — | — | — | — |
Median gas per op over its input ladder, 2026-10-15. The Yul object column includes the staticcall; the other six 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: aave aave-v3-origin@8305565ae342 (MathUtils, transcribed), abdk v3.2, balancer balancer-v3-monorepo@2b9ce4b1b8ad (LogExpMath.sol, vendored), forge forge Version: 1.7.1, fp127 279ec8a, huff sepolia:0xfae694D0c2c44181791F838c54Ed64C3151FfE30@11857616, maker dss pot.sol rpow via solady v0.1.26, morpho morpho-blue@8e26ca6a8dbc (MathLib, transcribed), prb-math v4.2.0, solady v0.1.26.
mul and div cost about what they cost in WAD. The transcendentals cost more because they compute twice the bits. Quad and FP256 (its table) pay for the moving point on every op. Only FP127 has erf, erfc, normCdf and Lambert W, and they are the expensive ones.
Precision per op
| op | vectors | reverts | min bits | mean bits | worst input |
|---|---|---|---|---|---|
| abs | 96 | 1 | exact | exact | |
| add | 381 | 19 | exact | exact | |
| atanh | 534 | 5 | 255 | 255 | 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff |
| avg | 200 | 0 | exact | exact | |
| cbrt | 96 | 1 | 123 | 152 | 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff |
| ceil | 95 | 2 | exact | exact | |
| clamp | 300 | 0 | exact | exact | |
| compound | 143 | 57 | 255 | 255 | 0xffffffffffffffffffffffffffffffff99b1728cae9854967465fd34ac880ac1,0x0000000000000000000000000000000a00000000000000000000000000000000 |
| cosh | 575 | 4 | 146 | 253 | 0x00000000000000000000000000000016a09e667f3bcc908b2fb1366ea957d3e3 |
| dist | 190 | 10 | exact | exact | |
| div | 377 | 23 | exact | exact | |
| erf | 571 | 0 | 255 | 255 | 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff |
| erfc | 571 | 0 | 255 | 255 | 0x0000000000000000000000000000000000000000000000000000000000000001 |
| exp | 87 | 4 | 146 | 221 | 0x0000000000000000000000000000001400000000000000000000000000000000 |
| exp10 | 66 | 3 | 146 | 211 | 0x0000000000000000000000000000000a00000000000000000000000000000000 |
| exp2 | 80 | 3 | 146 | 211 | 0x0000000000000000000000000000003200000000000000000000000000000000 |
| expm1 | 577 | 2 | 146 | 254 | 0x00000000000000000000000000000016a09e667f3bcc908b2fb1366ea957d3e3 |
| 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 |
| log1p | 561 | 18 | 255 | 255 | 0x0000000000000000000000000000000000000000000000000000000000000001 |
| 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 | |
| normCdf | 571 | 0 | 255 | 255 | 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff |
| pi | 8 | 7 | 122 | 139 | 0x0000000000000000000000000000000300000000000000000000000000000000 |
| pow | 369 | 31 | 124 | 235 | 0x0000000000000000000000000000003039d390f03ddfbfbc409fbb600262981a,0x0000000000000000000000000000001400000000000000000000000000000000 |
| powu | 302 | 98 | 255 | 255 | 0x000000000000000000000000000000015cbd69af9ce95a8ff0778c77c7993941,0x0000000000000000000000000000008000000000000000000000000000000000 |
| round | 95 | 2 | exact | exact | |
| sign | 97 | 0 | exact | exact | |
| sinh | 575 | 4 | 146 | 253 | 0x00000000000000000000000000000016a09e667f3bcc908b2fb1366ea957d3e3 |
| sqrt | 298 | 3 | exact | exact | |
| sub | 387 | 13 | exact | exact | |
| tanh | 579 | 0 | 255 | 255 | 0x0000000000000000000000000000000000000000000000000000000000000001 |
| 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: bit-exact.
ln,log2,log10: within one ULP. exp,exp2,exp10: 146 bits or better, the limit of the degree-24 polynomial.- Transcendentals use 64 guard bits and round to nearest once, so the error has no sign bias and iterated calls do not drift.
- Lambert W: 126 to 128 bits, except within 2^−20 of the branch point at −1/e, where one ULP of input moves the output by 2^−63.
powu,compound,erf,erfc,normCdf: within two ULP.expm1,sinh,cosh,tanh: 140 bits or better.log1p,atanh: one ULP.