function ceil
ceil(
x: number,
n?: number,
): number

Round toward positive infinity.

Rounds the input value(s) toward positive infinity, optionally to a specified number of decimal places.

Examples

Round a number (Math.PI) to 12 decimal places

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil(Math.PI, 12), 3.141592653590);

Round a number (3.78) toward positive infinity

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil(3.78), 4);

Round an array of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil([4.51, -1.4]), [5, -1]);

Round a matrix of numbers to 2 decimal places

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil([[4.5134, -1.4345], [3.7809, 0.0134]], 2), [[4.52, -1.43], [3.79, 0.02]]);

Parameters

x: number

Value(s) to be rounded

optional
n: number

Number of decimal places to round to (defaults to 0)

Return Type

number

The rounded value(s)

Throws

If no input is provided

ceil(
x: array,
n?: number,
): array

Round toward positive infinity.

Rounds the input value(s) toward positive infinity, optionally to a specified number of decimal places.

Examples

Round a number (Math.PI) to 12 decimal places

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil(Math.PI, 12), 3.141592653590);

Round a number (3.78) toward positive infinity

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil(3.78), 4);

Round an array of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil([4.51, -1.4]), [5, -1]);

Round a matrix of numbers to 2 decimal places

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil([[4.5134, -1.4345], [3.7809, 0.0134]], 2), [[4.52, -1.43], [3.79, 0.02]]);

Parameters

Value(s) to be rounded

optional
n: number

Number of decimal places to round to (defaults to 0)

Return Type

The rounded value(s)

Throws

If no input is provided

ceil(
x: matrix,
n?: number,
): matrix

Round toward positive infinity.

Rounds the input value(s) toward positive infinity, optionally to a specified number of decimal places.

Examples

Round a number (Math.PI) to 12 decimal places

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil(Math.PI, 12), 3.141592653590);

Round a number (3.78) toward positive infinity

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil(3.78), 4);

Round an array of numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil([4.51, -1.4]), [5, -1]);

Round a matrix of numbers to 2 decimal places

import { assertEquals } from "jsr:@std/assert";

assertEquals(ceil([[4.5134, -1.4345], [3.7809, 0.0134]], 2), [[4.52, -1.43], [3.79, 0.02]]);

Parameters

Value(s) to be rounded

optional
n: number

Number of decimal places to round to (defaults to 0)

Return Type

The rounded value(s)

Throws

If no input is provided