math

math is the lil-terminal function calculator: constants, rounding, powers, roots, logarithms, trigonometry, IEEE-754 checks and base conversion share one command surface.

DataVersion 1.1.4Stable
lil-terminal

Overview

math keeps routine calculations inside lil-terminal: constants, rounding, powers, roots, logarithms, trigonometry, IEEE-754 checks and base conversion all use the same compact command surface. Domain and division errors are reported explicitly, so the same examples work well both interactively and inside .lil scripts.

One function, one predictable operation

This is not an expression evaluator: name a function first, then pass its arguments. Domain and division checks are explicit, and trigonometric functions use radians; use deg2rad or rad2deg when working with degrees.

Syntax

lil-terminal
math <function> [args]

Reference

math pi

show mathematical constants pi or e

math e

show mathematical constants pi or e

math inf

show special floating-point values

math nan

show special floating-point values

math abs <n>

absolute value or sign of one number

math sign <n>

absolute value or sign of one number

math min <numbers>

minimum or maximum of one or more numbers

math max <numbers>

minimum or maximum of one or more numbers

math clamp <value> <min> <max>

limit a value to the selected range

math ceil <n>

round upward or downward

math floor <n>

round upward or downward

math round <n> [precision]

round with optional decimal precision

math pow <base> <exponent>

raise a number to a power

math fpow <base> <exponent>

raise a number to a power

math sqrt <n>

square or cube root

math cbrt <n>

square or cube root

math exp <n>

exponential functions

math expm1 <n>

exponential functions

math hypot <x> <y>

hypotenuse from two components

math intdiv <a> <b>

integer division

math fdiv <a> <b>

IEEE 754 floating-point division

math fmod <a> <b>

floating-point remainder

math log <n> [base]

natural or selected-base logarithm

math log10 <n>

base-10 logarithm or log(1+n)

math log1p <n>

base-10 logarithm or log(1+n)

math sin <rad>

trigonometric functions in radians

math cos <rad>

trigonometric functions in radians

math tan <rad>

trigonometric functions in radians

math asin <n>

inverse trigonometric functions

math acos <n>

inverse trigonometric functions

math atan <n>

inverse trigonometric functions

math atan2 <y> <x>

angle from two Cartesian components

math sinh <n>

hyperbolic functions

math cosh <n>

hyperbolic functions

math tanh <n>

hyperbolic functions

math asinh <n>

inverse hyperbolic functions

math acosh <n>

inverse hyperbolic functions

math atanh <n>

inverse hyperbolic functions

math deg2rad <n>

convert degrees and radians

math rad2deg <n>

convert degrees and radians

math is_finite <n>

inspect special floating-point values

math is_infinite <n>

inspect special floating-point values

math is_nan <n>

inspect special floating-point values

math base_convert <number> <from> <to>

convert an unsigned integer between bases 2–36

math bindec <number>

convert binary, hexadecimal or octal to decimal

math hexdec <number>

convert binary, hexadecimal or octal to decimal

math octdec <number>

convert binary, hexadecimal or octal to decimal

math decbin <number>

convert decimal to binary, hexadecimal or octal

math dechex <number>

convert decimal to binary, hexadecimal or octal

math decoct <number>

convert decimal to binary, hexadecimal or octal

Validation and errors

Arguments are validated before the mathematical operation runs. Domain-sensitive functions reject impossible inputs explicitly: math sqrt -1 returns a domain error, math intdiv 8 0 reports division by zero, and math log 10 1 rejects logarithm base 1. These predictable errors are useful when a calculation is being checked interactively or copied into a later script.

Number formats

Decimal arguments accept a dot; a single comma is also normalized as a decimal separator. pi, e, inf, -inf and nan can be supplied where a numeric argument is expected. Base conversion accepts unsigned integers and bases from 2 through 36.

Interactive sandbox preview

Run the prepared examples directly on the page. Their results are prebuilt and shown in the browser; no terminal command is executed on the server.

Show mathematical constants pi or e

Install and manage

Install the current compatible version. Choose Base for the complete feature set or Minimum for the reduced package; use upgrade to update a module that is already installed.

Base and Minimum are two packages of the same current module release, not separate command versions.

Base package

Install the complete package with local command reference and every published mode.

install math
Minimum package

Install the reduced package. Local reference is omitted; help <cmd> -i opens the current server reference.

install math -m
Exact public version

Install exactly this published version.

install math -v 1.1.4
Check or update

Ask upgrade to check compatibility and replace the installed block only when needed.

upgrade math
Remove module

Remove the extension block while leaving the core and unrelated modules intact.

install math -u

Examples

Examples are copyable command lines, not actions executed by this website. Review paths, permissions and destructive flags before running them on a real project.

Show mathematical constants pi or e
math pi
3.14159265358979
Math · absolute
math abs -8
8
Limit a value to the selected range
math clamp 120 0 100
100
Round with optional decimal precision
math round 12.3456 2
12.35
Square or cube root
math sqrt 81
9
Reject an invalid square root
math sqrt -1
Domain error
Integer division
math intdiv 17 5
3
Reject division by zero
math intdiv 8 0
Division by zero
Natural or selected-base logarithm
math log 1000 10
3
Trigonometric functions in radians
math sin 0
0
Trigonometric functions in radians
math sin 1
0.841470984807897
Reject an invalid inverse-trigonometric value
math asin 2
Domain error
Convert degrees and radians
math deg2rad 180
3.14159265358979
Convert an unsigned integer between bases 2–36
math base_convert 1010 2 16
a
Convert decimal to binary, hexadecimal or octal
math dechex 255
ff

Related documentation

Current public release

v1.1.42026-08-08

One function per line

Expands the local reference so every mathematical function has its own discoverable line.