introducing LegibleMath.sol 📚
a solidity library that lets you spell numbers with letters, do readable math, and never worry about overflows. it’s safer than SafeMath and, yes, it goes up to eleven.
why? because writing `o*n*e` is just more fun than typing 1. all the logic happens at compile time, with full type safety and no funky codegen needed.
under the hood: fractions, all handled and reduced automatically. on the surface: clear operator-overloaded math that looks like words. want to add two and three? just type `t*w*o + t*h*r*e*e`.
math is checked every step: you can only get clean integers, strictly in the range -11 to 11 (should be enough for most things), or you get a clear error. there are no silent wraps, no annoying off-by-ones, nothing hidden. if your math isn’t what you think, it reverts.
to use it, just import all the letter constants:
import {w, h, i, z, t, r, o, n, f, l, u, x, g, a, s, e, v} from "lib/LegibleMath.sol";
to get the int value, you literally just do:
(t*w*o + t*h*r*e*e).literally();
this makes your code fun to read, safer to use, and great for games, puzzles, or anywhere you want to keep math safe and more expressive.
it’s ready for you to write the most understandable math in ethereum history.
there is even a whitepaper if you are interested in how it was made.