Tea — a strongly typed scripting language
Tea
DocsPlaygroundExamplesReferenceCommunity
GitHub

Tea Language

A strongly typed scripting language for native tools.

© 2026 Tea Language.

Agent documentationContributingCommunityRepository

Language Runtime

Built-ins

Standard Library

std.argsstd.assertstd.audiostd.encodingstd.envstd.fsstd.hashstd.httpstd.netstd.jsonstd.mathstd.parsestd.pathstd.processstd.randomstd.raylibstd.regexstd.stringstd.timestd.url

Read as Markdown

Standard Library

std.math

Extended math: powers, logarithms, trigonometry, and float utilities.

Exported functions

pub def pi() -> Float

Return pi.

pub def e() -> Float

Return Euler's number e.

pub def pow(base: Float, exponent: Float) -> Float

Raise base to the given power.

Examples

use math from "std.math"

@println(math.pow(2.0, 10.0)) # 1024
pub def exp(value: Float) -> Float

Return e raised to the given power.

pub def log(value: Float) -> Float

Return the natural logarithm.

pub def log2(value: Float) -> Float

Return the base-2 logarithm.

Examples

use math from "std.math"

@println(math.log2(1024.0)) # 10
pub def log10(value: Float) -> Float

Return the base-10 logarithm.

pub def sin(value: Float) -> Float

Return the sine of an angle in radians.

Examples

use math from "std.math"

const radians = 90.0 * math.pi() / 180.0
@println(math.sin(radians)) # 1
pub def cos(value: Float) -> Float

Return the cosine of an angle in radians.

pub def tan(value: Float) -> Float

Return the tangent of an angle in radians.

pub def asin(value: Float) -> Float

Return the arcsine in radians.

pub def acos(value: Float) -> Float

Return the arccosine in radians.

pub def atan(value: Float) -> Float

Return the arctangent in radians.

pub def atan2(y: Float, x: Float) -> Float

Return the four-quadrant arctangent of y/x in radians.

pub def hypot(x: Float, y: Float) -> Float

Return sqrt(x^2 + y^2) without intermediate overflow.

Examples

use math from "std.math"

@println(math.hypot(3.0, 4.0)) # 5
pub def trunc(value: Float) -> Int

Truncate toward zero, returning an Int.

pub def sign(value: Float) -> Int

Return -1, 0, or 1 according to the sign of the value.

pub def clamp(value: Float, low: Float, high: Float) -> Float

Clamp a value into the inclusive range [low, high].

Examples

use math from "std.math"

@println(math.clamp(1.5, 0.0, 1.0)) # 1
pub def floor(value: Float) -> Int

Round down to the nearest integer (same as the @floor builtin).

pub def ceil(value: Float) -> Int

Round up to the nearest integer (same as the @ceil builtin).

pub def round(value: Float) -> Int

Round to the nearest integer (same as the @round builtin).

Examples

use math from "std.math"

@println(math.round(3.6)) # 4
@println(math.trunc(3.6)) # 3
pub def abs(value: Float) -> Float

Return the absolute value (same as the @abs builtin).

pub def sqrt(value: Float) -> Float

Return the square root (same as the @sqrt builtin).

pub def min(a: Float, b: Float) -> Float

Return the smaller of two values (same as the @min builtin).

pub def max(a: Float, b: Float) -> Float

Return the larger of two values (same as the @max builtin).