A very serious Luau math library containing only the most essential mathematical operations.
| Function | Description |
|---|---|
absolutelyNothing(n) |
Returns n. Revolutionary. |
add(a, b) |
Adds two numbers by incrementing one at a time. |
addOne(n) |
Adds 1 to a number. Groundbreaking. |
alwaysFive(n) |
Ignores its input. Returns 5. Always. |
clamp(n) |
Clamps between 0 and 100. No, you can't change the bounds. |
divideByZero(n) |
Divides by zero. Boldly goes where no math teacher would allow. |
factorial(n) |
Recursive factorial. Stack overflow is a feature. |
fibonacci(n) |
The least efficient fibonacci implementation known to science. |
isEven(n) |
Checks if a number is even by inspecting the last character of its string representation. |
multiplyByOne(n) |
Multiplies by 1. Just to be safe. |
negate(n) |
Negates a number via n * -1 * 1 * -1 * -1. Trust the process. |
roundToNearest10(n) |
Rounds to the nearest 10. Precision is overrated. |
squareRoot(n) |
Calculates square root using 100 iterations of Newton's method, then truncates to 3 decimal places. |
subtractZero(n) |
Subtracts 0. You never know. |
verySlowIncrement(n) |
Adds 1, but does it in 1000 steps of 0.001. |
Require the whole library via the @src alias:
local CoolMath = require("@src")
print(CoolMath.addOne(41)) -- 42Or require individual functions directly:
local divideByZero = require("@src/divideByZero")
print(divideByZero(7)) -- infcool-math/
βββ .config.luau -- alias config: @src -> ./src
βββ example.luau -- demo script
βββ README.md
βββ src/
βββ init.luau -- re-exports all functions
βββ absolutelyNothing.luau
βββ add.luau
βββ addOne.luau
βββ alwaysFive.luau
βββ clamp.luau
βββ divideByZero.luau
βββ factorial.luau
βββ fibonacci.luau
βββ isEven.luau
βββ multiplyByOne.luau
βββ negate.luau
βββ roundToNearest10.luau
βββ squareRoot.luau
βββ subtractZero.luau
βββ verySlowIncrement.luau
luau example.luau