Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

math floor for math

Returns the floor of a number (largest integer less than or equal to that number).

Signature

> math floor {flags} ...rest

Parameters

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

Input/output types:

inputoutput
numberint
durationduration
filesizefilesize
list<number>list<int>
list<duration>list<duration>
list<filesize>list<filesize>
rangelist<number>
recordrecord

Examples

Apply the floor function to a list of numbers.

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

Apply the floor function to list-valued columns in a record.

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

Apply the floor function to a single column using a cell path.

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

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

> 2.1KB | math floor
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 floor is the identity function for those types.