math ceil

For math.

Returns the ceil of a number (smallest integer greater than or equal to that number).

Command Type

built-in

Signature

> math ceil {flags} ...rest

Parameters

  • ...rest: The cell-paths/columns to operate on.

Input/output types:

input output
number int
duration duration
filesize filesize
list<number> list<int>
list<duration> list<duration>
list<filesize> list<filesize>
range list<number>
record record

Examples

Apply the ceil function to a list of numbers.

> [1.5 2.3 -3.1] | math ceil
╭───┬────╮
│ 0 │  2 │
│ 1 │  3 │
│ 2 │ -3 │
╰───┴────╯

Apply ceiling to list-valued columns in a record.

> {alice: [1.2 2.7 3.5], bob: [4.1 5.9]} | math ceil
╭───────┬───────────╮
│       │ ╭───┬───╮ │
│ alice │ │ 0 │ 2 │ │
│       │ │ 1 │ 3 │ │
│       │ │ 2 │ 4 │ │
│       │ ╰───┴───╯ │
│       │ ╭───┬───╮ │
│ bob   │ │ 0 │ 5 │ │
│       │ │ 1 │ 6 │ │
│       │ ╰───┴───╯ │
╰───────┴───────────╯

Apply ceiling to a single column using a cell path.

> {alice: [1.2 2.7 3.5], bob: [4.1 5.9]} | math ceil alice
╭───────┬──────────────╮
│       │ ╭───┬───╮    │
│ alice │ │ 0 │ 2 │    │
│       │ │ 1 │ 3 │    │
│       │ │ 2 │ 4 │    │
│       │ ╰───┴───╯    │
│       │ ╭───┬──────╮ │
│ bob   │ │ 0 │ 4.10 │ │
│       │ │ 1 │ 5.90 │ │
│       │ ╰───┴──────╯ │
╰───────┴──────────────╯

Filesize values are already whole bytes, so ceiling is a no-op.

> 2.1KB | math ceil
2.1 kB

Notes

Filesize and duration values are stored as integers in base units (bytes and nanoseconds). With no display unit to round against, math ceil is the identity function for those types.

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.