llm
Download
806 lines 15.6 KiBMarkdownModified 2026-08-30 raw

Builtins

Num

Num.PI

Num.PI : Num

The ratio of a circle's circumference to its diameter, held exactly rather than as an approximation.

Example:

assert Num.PI.sin() == 0
assert Num.PI.digits(10) == "3.1415926535…"

Num.TAU

Num.TAU : Num

Two times pi, held exactly.

Example:

assert Num.TAU == 2 * Num.PI

Num.abs

Num.abs : func(x: Num -> Num)

The absolute value of a number.

Argument Type Description Default
x Num The number whose absolute value is to be computed. -

Return: The absolute value of x.

Example:

assert (-3.5).abs() == 3.5

Num.acos

Num.acos : func(x: Num -> Num?)

The arc cosine of a number, in radians.

Argument Type Description Default
x Num The number whose arc cosine is to be computed. -

Return: The arc cosine of x, or none if x is outside [-1, 1].

Example:

assert (1.).acos()! == 0
assert (2.).acos() == none

Num.asin

Num.asin : func(x: Num -> Num?)

The arc sine of a number, in radians.

Argument Type Description Default
x Num The number whose arc sine is to be computed. -

Return: The arc sine of x, or none if x is outside [-1, 1].

Example:

assert (0.).asin()! == 0
assert (2.).asin() == none

Num.atan

Num.atan : func(x: Num -> Num)

The arc tangent of a number, in radians. Defined for every number.

Argument Type Description Default
x Num The number whose arc tangent is to be computed. -

Return: The arc tangent of x.

Example:

assert (0.).atan() == 0
assert (1.).atan() == Num.PI / 4

Num.atan2

Num.atan2 : func(y: Num, x: Num -> Num?)

The angle of the point (x, y), in radians, placed in the correct quadrant by the signs of both arguments.

Argument Type Description Default
y Num The y coordinate. -
x Num The x coordinate. -

Return: The angle in (-pi, pi], or none at the origin, where no angle is defined.

Example:

assert (1.).atan2(1)! == Num.PI / 4
assert (0.).atan2(0) == none

Num.ceil

Num.ceil : func(x: Num -> Num)

The smallest whole number greater than or equal to a number.

Argument Type Description Default
x Num The number to round up. -

Return: x rounded up.

Example:

assert (4.2).ceil() == 5
assert (-4.2).ceil() == -4

Num.clamped

Num.clamped : func(x: Num, low: Num, high: Num -> Num)

A number restricted to a range.

Argument Type Description Default
x Num The number to clamp. -
low Num The lowest allowed value. -
high Num The highest allowed value. -

Return: x, or the nearer of low and high if x falls outside them.

Example:

assert (1.5).clamped(0, 1) == 1
assert (0.5).clamped(0, 1) == 0.5

Num.cos

Num.cos : func(x: Num -> Num)

The cosine of an angle in radians.

Argument Type Description Default
x Num The angle in radians. -

Return: The cosine of x.

Example:

assert (0.).cos() == 1
assert Num.PI.cos() == -1

Num.cosh

Num.cosh : func(x: Num -> Num)

The hyperbolic cosine of a number.

Argument Type Description Default
x Num The number whose hyperbolic cosine is to be computed. -

Return: The hyperbolic cosine of x.

Example:

assert (0.).cosh() == 1

Num.digits

Num.digits : func(n: Num, digits: Int = 15, ellipsis: Text = "…" -> Text)

The decimal expansion of a number, to at most the requested number of fractional digits. A value that fits exactly stops early rather than padding with zeros, and gets no marker. A value that doesn't shows a truncated prefix of its true expansion with the ellipsis appended, and never a rounding: every digit shown is a digit the value actually has. To round, round first.

Argument Type Description Default
n Num The number to expand. -
digits Int The maximum number of fractional digits. 15
ellipsis Text Appended when the digits don't capture the value exactly. "…"

Return: The decimal expansion as text.

Example:

assert (1/3).digits(10) == "0.3333333333…"
assert Num.PI.digits(10) == "3.1415926535…"
assert (2/3).digits(10, ellipsis="") == "0.6666666666"
assert (0.25).digits(10) == "0.25"

Num.exp

Num.exp : func(x: Num -> Num)

e raised to the given power.

Argument Type Description Default
x Num The exponent. -

Return: e to the power of x.

Example:

assert (0.).exp() == 1

Num.floor

Num.floor : func(x: Num -> Num)

The largest whole number less than or equal to a number.

Argument Type Description Default
x Num The number to round down. -

Return: x rounded down.

Example:

assert (4.8).floor() == 4
assert (-4.2).floor() == -5

Num.gcd

Num.gcd : func(x: Num, y: Num -> Num?)

The greatest common divisor of two numbers, generalized to fractions: the largest value by which both can be divided to give whole numbers.

Argument Type Description Default
x Num The first number. -
y Num The second number. -

Return: The greatest common divisor, or none if either argument is irrational and so has no such divisor.

Example:

assert (12.).gcd(18)! == 6
assert (1./2.).gcd(1./3.)! == 1./6.

Num.inverse

Num.inverse : func(x: Num -> Num?)

One divided by a number.

Argument Type Description Default
x Num The number to invert. -

Return: The reciprocal of x, or none if x is zero.

Example:

assert (4.).inverse()! == 0.25
assert (0.).inverse() == none

Num.is_between

Num.is_between : func(x: Num, low: Num, high: Num -> Bool)

Whether a number lies within a range, inclusive.

Argument Type Description Default
x Num The number to check. -
low Num The lower bound. -
high Num The upper bound. -

Return: yes if low <= x <= high.

Example:

assert (0.5).is_between(0, 1)
assert not (1.5).is_between(0, 1)

Num.is_exact

Num.is_exact : func(n: Num, digits: Int = 15 -> Bool)

Whether the requested number of fractional digits represents a number exactly, rather than rounding it.

Argument Type Description Default
n Num The number to check. -
digits Int The number of fractional digits. 15

Return: yes if :digits(digits) is the value itself.

Example:

assert (0.25).is_exact(10)
assert not (1./3.).is_exact(10)

Num.is_integer

Num.is_integer : func(n: Num -> Bool)

Whether a number is a whole number.

Argument Type Description Default
n Num The number to check. -

Return: yes if n has no fractional part.

Example:

assert (4.).is_integer()
assert not (4.5).is_integer()

Num.is_rational

Num.is_rational : func(n: Num -> Bool)

Whether a number can be written exactly as a fraction, as opposed to an irrational value like the square root of two.

Argument Type Description Default
n Num The number to check. -

Return: yes if n is rational.

Example:

assert (1./3.).is_rational()
assert not (2.).sqrt()!.is_rational()

Num.lcm

Num.lcm : func(x: Num, y: Num -> Num?)

The least common multiple of two numbers, generalized to fractions.

Argument Type Description Default
x Num The first number. -
y Num The second number. -

Return: The least common multiple, or none if either argument is irrational.

Example:

assert (4.).lcm(6)! == 12

Num.log

Num.log : func(x: Num -> Num?)

The natural logarithm of a number.

Argument Type Description Default
x Num The number whose logarithm is to be computed. -

Return: The natural log of x, or none if x is not positive.

Example:

assert (1.).log()! == 0
assert (0.).log() == none

Num.log10

Num.log10 : func(x: Num -> Num?)

The base-10 logarithm of a number.

Argument Type Description Default
x Num The number whose logarithm is to be computed. -

Return: The base-10 log of x, or none if x is not positive.

Example:

assert (100.).log10()! == 2

Num.log2

Num.log2 : func(x: Num -> Num?)

The base-2 logarithm of a number.

Argument Type Description Default
x Num The number whose logarithm is to be computed. -

Return: The base-2 log of x, or none if x is not positive.

Example:

assert (8.).log2()! == 3
assert (1./4.).log2()! == -2

Num.max

Num.max : func(x: Num, y: Num -> Num)

The larger of two numbers.

Argument Type Description Default
x Num The first number. -
y Num The second number. -

Return: Whichever of x and y is larger.

Example:

assert (0.3).max(0.5) == 0.5

Num.min

Num.min : func(x: Num, y: Num -> Num)

The smaller of two numbers.

Argument Type Description Default
x Num The first number. -
y Num The second number. -

Return: Whichever of x and y is smaller.

Example:

assert (0.3).min(0.5) == 0.3

Num.mix

Num.mix : func(amount: Num, x: Num, y: Num -> Num)

A point between two numbers, exactly. amount of zero gives x, one gives y, and a half gives the true midpoint.

Argument Type Description Default
amount Num How far from x toward y. -
x Num The value at amount zero. -
y Num The value at amount one. -

Return: The interpolated value.

Example:

assert (0.25).mix(10, 20) == 12.5
assert (1./3.).mix(0, 1) == 1./3.

Num.parse

Num.parse : func(text: Text -> Num?)

The exact number a piece of text denotes. Both decimals and fractions are accepted, and both are read exactly: "0.1" is a tenth, not the nearest float to one.

Argument Type Description Default
text Text The text to parse. -

Return: The number, or none if the text isn't one.

Example:

assert Num.parse("0.1")! == 0.1
assert Num.parse("22/7")! == 22./7.
assert Num.parse("nope") == none

Num.percent

Num.percent : func(n: Num, precision: Num = 1% -> Text)

A number as a percentage, rounded to the given precision.

Argument Type Description Default
n Num The number to format. -
precision Num Round the percentage to this precision. 1%

Return: The percentage, with a percent sign.

Example:

assert (0.5).percent() == "50%"
assert (1./3.).percent() == "33%"
assert (1./3.).percent(0.01%) == "33.33%"

Num.round

Num.round : func(x: Num, increment: Num = 1 -> Num)

The nearest multiple of an increment, exactly: the nearest penny, nickel, third, or thousand are all one argument away, and the default increment of 1 gives the nearest whole number. Ties go to the even multiple.

Argument Type Description Default
x Num The number to round. -
increment Num The step to round to a multiple of. Rounding to zero is an error. 1

Return: x rounded to the nearest multiple of increment.

Example:

assert (4.6).round() == 5
assert (2.5).round() == 2
assert (3.14159).round(0.01) == 3.14
assert (0.13).round(0.05) == 0.15
assert (0.5).round(1/3) == 2/3
assert (1234567.).round(1000) == 1235000

Num.sin

Num.sin : func(x: Num -> Num)

The sine of an angle in radians.

Argument Type Description Default
x Num The angle in radians. -

Return: The sine of x.

Example:

assert (0.).sin() == 0
assert Num.PI.sin() == 0

Num.sinh

Num.sinh : func(x: Num -> Num)

The hyperbolic sine of a number.

Argument Type Description Default
x Num The number whose hyperbolic sine is to be computed. -

Return: The hyperbolic sine of x.

Example:

assert (0.).sinh() == 0

Num.sqrt

Num.sqrt : func(x: Num -> Num?)

The square root of a number, exactly. The result of a non-square stays symbolic, so identities like sqrt(2) * sqrt(2) == 2 hold.

Argument Type Description Default
x Num The number whose square root is to be computed. -

Return: The square root of x, or none if x is negative.

Example:

assert (16.).sqrt()! == 4
assert (2.).sqrt()! * (2.).sqrt()! == 2
assert (-1.).sqrt() == none

Num.symbolic

Num.symbolic : func(n: Num -> Text)

The exact value written out: a whole number, a fraction, or a symbolic expression for an irrational.

Argument Type Description Default
n Num The number to write out. -

Return: The exact form.

Example:

assert (1./3.).symbolic() == "1/3"
assert (2.).sqrt()!.symbolic() == "sqrt(2)"
assert Num.PI.symbolic() == "pi"

Num.tan

Num.tan : func(x: Num -> Num?)

The tangent of an angle in radians.

Argument Type Description Default
x Num The angle in radians. -

Return: The tangent of x, or none at a pole.

Example:

assert (0.).tan()! == 0

Num.tanh

Num.tanh : func(x: Num -> Num)

The hyperbolic tangent of a number.

Argument Type Description Default
x Num The number whose hyperbolic tangent is to be computed. -

Return: The hyperbolic tangent of x.

Example:

assert (0.).tanh() == 0

Num.tex

Num.tex : func(n: Num -> Text)

The exact value as TeX math-mode source.

Argument Type Description Default
n Num The number to render. -

Return: The TeX source.

Example:

assert (1./3.).tex() == "\\frac{1}{3}"
assert (2.).sqrt()!.tex() == "\\sqrt{2}"

Num.trunc

Num.trunc : func(x: Num -> Num)

The whole part of a number, discarding the fraction.

Argument Type Description Default
x Num The number to truncate. -

Return: x with its fractional part removed.

Example:

assert (4.8).trunc() == 4
assert (-4.8).trunc() == -4

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
% API

# Builtins

# Num
## Num.PI

```tomo
Num.PI : Num
```

The ratio of a circle's circumference to its diameter, held exactly rather than as an approximation.


**Example:**
```tomo
assert Num.PI.sin() == 0
assert Num.PI.digits(10) == "3.1415926535…"

```
## Num.TAU

```tomo
Num.TAU : Num
```

Two times pi, held exactly.


**Example:**
```tomo
assert Num.TAU == 2 * Num.PI

```
## Num.abs

```tomo
Num.abs : func(x: Num -> Num)
```

The absolute value of a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose absolute value is to be computed.  | -

**Return:** The absolute value of `x`.


**Example:**
```tomo
assert (-3.5).abs() == 3.5

```
## Num.acos

```tomo
Num.acos : func(x: Num -> Num?)
```

The arc cosine of a number, in radians.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose arc cosine is to be computed.  | -

**Return:** The arc cosine of `x`, or `none` if `x` is outside [-1, 1].


**Example:**
```tomo
assert (1.).acos()! == 0
assert (2.).acos() == none

```
## Num.asin

```tomo
Num.asin : func(x: Num -> Num?)
```

The arc sine of a number, in radians.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose arc sine is to be computed.  | -

**Return:** The arc sine of `x`, or `none` if `x` is outside [-1, 1].


**Example:**
```tomo
assert (0.).asin()! == 0
assert (2.).asin() == none

```
## Num.atan

```tomo
Num.atan : func(x: Num -> Num)
```

The arc tangent of a number, in radians. Defined for every number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose arc tangent is to be computed.  | -

**Return:** The arc tangent of `x`.


**Example:**
```tomo
assert (0.).atan() == 0
assert (1.).atan() == Num.PI / 4

```
## Num.atan2

```tomo
Num.atan2 : func(y: Num, x: Num -> Num?)
```

The angle of the point `(x, y)`, in radians, placed in the correct quadrant by the signs of both arguments.

Argument | Type | Description | Default
---------|------|-------------|---------
y | `Num` | The y coordinate.  | -
x | `Num` | The x coordinate.  | -

**Return:** The angle in (-pi, pi], or `none` at the origin, where no angle is defined.


**Example:**
```tomo
assert (1.).atan2(1)! == Num.PI / 4
assert (0.).atan2(0) == none

```
## Num.ceil

```tomo
Num.ceil : func(x: Num -> Num)
```

The smallest whole number greater than or equal to a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number to round up.  | -

**Return:** `x` rounded up.


**Example:**
```tomo
assert (4.2).ceil() == 5
assert (-4.2).ceil() == -4

```
## Num.clamped

```tomo
Num.clamped : func(x: Num, low: Num, high: Num -> Num)
```

A number restricted to a range.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number to clamp.  | -
low | `Num` | The lowest allowed value.  | -
high | `Num` | The highest allowed value.  | -

**Return:** `x`, or the nearer of `low` and `high` if `x` falls outside them.


**Example:**
```tomo
assert (1.5).clamped(0, 1) == 1
assert (0.5).clamped(0, 1) == 0.5

```
## Num.cos

```tomo
Num.cos : func(x: Num -> Num)
```

The cosine of an angle in radians.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The angle in radians.  | -

**Return:** The cosine of `x`.


**Example:**
```tomo
assert (0.).cos() == 1
assert Num.PI.cos() == -1

```
## Num.cosh

```tomo
Num.cosh : func(x: Num -> Num)
```

The hyperbolic cosine of a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose hyperbolic cosine is to be computed.  | -

**Return:** The hyperbolic cosine of `x`.


**Example:**
```tomo
assert (0.).cosh() == 1

```
## Num.digits

```tomo
Num.digits : func(n: Num, digits: Int = 15, ellipsis: Text = "…" -> Text)
```

The decimal expansion of a number, to at most the requested number of fractional digits. A value that fits exactly stops early rather than padding with zeros, and gets no marker. A value that doesn't shows a truncated prefix of its true expansion with the ellipsis appended, and never a rounding: every digit shown is a digit the value actually has. To round, round first.

Argument | Type | Description | Default
---------|------|-------------|---------
n | `Num` | The number to expand.  | -
digits | `Int` | The maximum number of fractional digits.  | `15`
ellipsis | `Text` | Appended when the digits don't capture the value exactly.  | `"…"`

**Return:** The decimal expansion as text.


**Example:**
```tomo
assert (1/3).digits(10) == "0.3333333333…"
assert Num.PI.digits(10) == "3.1415926535…"
assert (2/3).digits(10, ellipsis="") == "0.6666666666"
assert (0.25).digits(10) == "0.25"

```
## Num.exp

```tomo
Num.exp : func(x: Num -> Num)
```

e raised to the given power.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The exponent.  | -

**Return:** e to the power of `x`.


**Example:**
```tomo
assert (0.).exp() == 1

```
## Num.floor

```tomo
Num.floor : func(x: Num -> Num)
```

The largest whole number less than or equal to a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number to round down.  | -

**Return:** `x` rounded down.


**Example:**
```tomo
assert (4.8).floor() == 4
assert (-4.2).floor() == -5

```
## Num.gcd

```tomo
Num.gcd : func(x: Num, y: Num -> Num?)
```

The greatest common divisor of two numbers, generalized to fractions: the largest value by which both can be divided to give whole numbers.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The first number.  | -
y | `Num` | The second number.  | -

**Return:** The greatest common divisor, or `none` if either argument is irrational and so has no such divisor.


**Example:**
```tomo
assert (12.).gcd(18)! == 6
assert (1./2.).gcd(1./3.)! == 1./6.

```
## Num.inverse

```tomo
Num.inverse : func(x: Num -> Num?)
```

One divided by a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number to invert.  | -

**Return:** The reciprocal of `x`, or `none` if `x` is zero.


**Example:**
```tomo
assert (4.).inverse()! == 0.25
assert (0.).inverse() == none

```
## Num.is_between

```tomo
Num.is_between : func(x: Num, low: Num, high: Num -> Bool)
```

Whether a number lies within a range, inclusive.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number to check.  | -
low | `Num` | The lower bound.  | -
high | `Num` | The upper bound.  | -

**Return:** `yes` if `low <= x <= high`.


**Example:**
```tomo
assert (0.5).is_between(0, 1)
assert not (1.5).is_between(0, 1)

```
## Num.is_exact

```tomo
Num.is_exact : func(n: Num, digits: Int = 15 -> Bool)
```

Whether the requested number of fractional digits represents a number exactly, rather than rounding it.

Argument | Type | Description | Default
---------|------|-------------|---------
n | `Num` | The number to check.  | -
digits | `Int` | The number of fractional digits.  | `15`

**Return:** `yes` if `:digits(digits)` is the value itself.


**Example:**
```tomo
assert (0.25).is_exact(10)
assert not (1./3.).is_exact(10)

```
## Num.is_integer

```tomo
Num.is_integer : func(n: Num -> Bool)
```

Whether a number is a whole number.

Argument | Type | Description | Default
---------|------|-------------|---------
n | `Num` | The number to check.  | -

**Return:** `yes` if `n` has no fractional part.


**Example:**
```tomo
assert (4.).is_integer()
assert not (4.5).is_integer()

```
## Num.is_rational

```tomo
Num.is_rational : func(n: Num -> Bool)
```

Whether a number can be written exactly as a fraction, as opposed to an irrational value like the square root of two.

Argument | Type | Description | Default
---------|------|-------------|---------
n | `Num` | The number to check.  | -

**Return:** `yes` if `n` is rational.


**Example:**
```tomo
assert (1./3.).is_rational()
assert not (2.).sqrt()!.is_rational()

```
## Num.lcm

```tomo
Num.lcm : func(x: Num, y: Num -> Num?)
```

The least common multiple of two numbers, generalized to fractions.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The first number.  | -
y | `Num` | The second number.  | -

**Return:** The least common multiple, or `none` if either argument is irrational.


**Example:**
```tomo
assert (4.).lcm(6)! == 12

```
## Num.log

```tomo
Num.log : func(x: Num -> Num?)
```

The natural logarithm of a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose logarithm is to be computed.  | -

**Return:** The natural log of `x`, or `none` if `x` is not positive.


**Example:**
```tomo
assert (1.).log()! == 0
assert (0.).log() == none

```
## Num.log10

```tomo
Num.log10 : func(x: Num -> Num?)
```

The base-10 logarithm of a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose logarithm is to be computed.  | -

**Return:** The base-10 log of `x`, or `none` if `x` is not positive.


**Example:**
```tomo
assert (100.).log10()! == 2

```
## Num.log2

```tomo
Num.log2 : func(x: Num -> Num?)
```

The base-2 logarithm of a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose logarithm is to be computed.  | -

**Return:** The base-2 log of `x`, or `none` if `x` is not positive.


**Example:**
```tomo
assert (8.).log2()! == 3
assert (1./4.).log2()! == -2

```
## Num.max

```tomo
Num.max : func(x: Num, y: Num -> Num)
```

The larger of two numbers.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The first number.  | -
y | `Num` | The second number.  | -

**Return:** Whichever of `x` and `y` is larger.


**Example:**
```tomo
assert (0.3).max(0.5) == 0.5

```
## Num.min

```tomo
Num.min : func(x: Num, y: Num -> Num)
```

The smaller of two numbers.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The first number.  | -
y | `Num` | The second number.  | -

**Return:** Whichever of `x` and `y` is smaller.


**Example:**
```tomo
assert (0.3).min(0.5) == 0.3

```
## Num.mix

```tomo
Num.mix : func(amount: Num, x: Num, y: Num -> Num)
```

A point between two numbers, exactly. `amount` of zero gives `x`, one gives `y`, and a half gives the true midpoint.

Argument | Type | Description | Default
---------|------|-------------|---------
amount | `Num` | How far from `x` toward `y`.  | -
x | `Num` | The value at `amount` zero.  | -
y | `Num` | The value at `amount` one.  | -

**Return:** The interpolated value.


**Example:**
```tomo
assert (0.25).mix(10, 20) == 12.5
assert (1./3.).mix(0, 1) == 1./3.

```
## Num.parse

```tomo
Num.parse : func(text: Text -> Num?)
```

The exact number a piece of text denotes. Both decimals and fractions are accepted, and both are read exactly: "0.1" is a tenth, not the nearest float to one.

Argument | Type | Description | Default
---------|------|-------------|---------
text | `Text` | The text to parse.  | -

**Return:** The number, or `none` if the text isn't one.


**Example:**
```tomo
assert Num.parse("0.1")! == 0.1
assert Num.parse("22/7")! == 22./7.
assert Num.parse("nope") == none

```
## Num.percent

```tomo
Num.percent : func(n: Num, precision: Num = 1% -> Text)
```

A number as a percentage, rounded to the given precision.

Argument | Type | Description | Default
---------|------|-------------|---------
n | `Num` | The number to format.  | -
precision | `Num` | Round the percentage to this precision.  | `1%`

**Return:** The percentage, with a percent sign.


**Example:**
```tomo
assert (0.5).percent() == "50%"
assert (1./3.).percent() == "33%"
assert (1./3.).percent(0.01%) == "33.33%"

```
## Num.round

```tomo
Num.round : func(x: Num, increment: Num = 1 -> Num)
```

The nearest multiple of an increment, exactly: the nearest penny, nickel, third, or thousand are all one argument away, and the default increment of 1 gives the nearest whole number. Ties go to the even multiple.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number to round.  | -
increment | `Num` | The step to round to a multiple of. Rounding to zero is an error.  | `1`

**Return:** `x` rounded to the nearest multiple of `increment`.


**Example:**
```tomo
assert (4.6).round() == 5
assert (2.5).round() == 2
assert (3.14159).round(0.01) == 3.14
assert (0.13).round(0.05) == 0.15
assert (0.5).round(1/3) == 2/3
assert (1234567.).round(1000) == 1235000

```
## Num.sin

```tomo
Num.sin : func(x: Num -> Num)
```

The sine of an angle in radians.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The angle in radians.  | -

**Return:** The sine of `x`.


**Example:**
```tomo
assert (0.).sin() == 0
assert Num.PI.sin() == 0

```
## Num.sinh

```tomo
Num.sinh : func(x: Num -> Num)
```

The hyperbolic sine of a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose hyperbolic sine is to be computed.  | -

**Return:** The hyperbolic sine of `x`.


**Example:**
```tomo
assert (0.).sinh() == 0

```
## Num.sqrt

```tomo
Num.sqrt : func(x: Num -> Num?)
```

The square root of a number, exactly. The result of a non-square stays symbolic, so identities like `sqrt(2) * sqrt(2) == 2` hold.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose square root is to be computed.  | -

**Return:** The square root of `x`, or `none` if `x` is negative.


**Example:**
```tomo
assert (16.).sqrt()! == 4
assert (2.).sqrt()! * (2.).sqrt()! == 2
assert (-1.).sqrt() == none

```
## Num.symbolic

```tomo
Num.symbolic : func(n: Num -> Text)
```

The exact value written out: a whole number, a fraction, or a symbolic expression for an irrational.

Argument | Type | Description | Default
---------|------|-------------|---------
n | `Num` | The number to write out.  | -

**Return:** The exact form.


**Example:**
```tomo
assert (1./3.).symbolic() == "1/3"
assert (2.).sqrt()!.symbolic() == "sqrt(2)"
assert Num.PI.symbolic() == "pi"

```
## Num.tan

```tomo
Num.tan : func(x: Num -> Num?)
```

The tangent of an angle in radians.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The angle in radians.  | -

**Return:** The tangent of `x`, or `none` at a pole.


**Example:**
```tomo
assert (0.).tan()! == 0

```
## Num.tanh

```tomo
Num.tanh : func(x: Num -> Num)
```

The hyperbolic tangent of a number.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number whose hyperbolic tangent is to be computed.  | -

**Return:** The hyperbolic tangent of `x`.


**Example:**
```tomo
assert (0.).tanh() == 0

```
## Num.tex

```tomo
Num.tex : func(n: Num -> Text)
```

The exact value as TeX math-mode source.

Argument | Type | Description | Default
---------|------|-------------|---------
n | `Num` | The number to render.  | -

**Return:** The TeX source.


**Example:**
```tomo
assert (1./3.).tex() == "\\frac{1}{3}"
assert (2.).sqrt()!.tex() == "\\sqrt{2}"

```
## Num.trunc

```tomo
Num.trunc : func(x: Num -> Num)
```

The whole part of a number, discarding the fraction.

Argument | Type | Description | Default
---------|------|-------------|---------
x | `Num` | The number to truncate.  | -

**Return:** `x` with its fractional part removed.


**Example:**
```tomo
assert (4.8).trunc() == 4
assert (-4.8).trunc() == -4

```