Skip to content

othomson-roblox/cool-math

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

cool-math

A very serious Luau math library containing only the most essential mathematical operations.

Functions

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.

Usage

Require the whole library via the @src alias:

local CoolMath = require("@src")
print(CoolMath.addOne(41)) -- 42

Or require individual functions directly:

local divideByZero = require("@src/divideByZero")
print(divideByZero(7)) -- inf

Project Structure

cool-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

Running

luau example.luau

About

A very serious Luau math library containing only the most essential mathematical operations.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages