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
  • Language Reference Guide
    • Readme
    • Types in the Nu Language
      • Basic Types
        • Any
        • Boolean
        • Integer
        • Float
        • Filesize
        • Duration
        • Datetime
        • Range
        • String
        • Record
        • List
        • Table
        • Closure
        • Nothing
        • Binary
        • Glob
        • Cell-Path
      • Other Data Types

        • Types used only in command signatures
          • Path
        • Types which are not declarable
          • Error
          • CustomValue
          • Block
      • Type signatures
      • Commands that interact with types
    • Operators
    • Flow control
      • if/else
      • loop
      • while
      • match
      • try/catch
      • break
      • return
      • continue
    • Filters
      • each and par-each
      • Filters to select subsets of data
      • where and filter
      • Understanding the difference between get and select
    • Custom Commands
    • Declarations
    • Variable Scope
    • Strings and Text Formatting
    • Helpers and debugging commands
    • Pipelines
    • MIME Types for Nushell

Integer

Description:Numbers without a fractional component (positive, negative, and 0)
Annotation:int
Literal syntax:A decimal, hex, octal, or binary numeric value without a decimal place. E.g., -100, 0, 50, +50, 0xff (hex), 0o234 (octal), 0b10101 (binary)
Casts:into int
See also:Types of Data - Integers

Additional Language Notes

  • Integers are internally represented as signed 64-bit numbers with two's-complement arithmetic. An operation that overflows this range raises an operator_overflow error rather than wrapping around.

  • Underscores can be used as digit separators in literals, e.g. 1_000_000.

  • The / operator always returns a float. Use // for floor division, which returns an int. mod uses the same floor semantics, so the result has the sign of the divisor:

    7 / 2
    # => 3.5
    7 // 2
    # => 3
    -7 // 2
    # => -4
    -7 mod 3
    # => 2

Common commands that can be used with int

  • into int, into float
  • math subcommands (see help math for a list)
  • bits subcommands (see help bits for a list)
  • format bits to show the binary representation, e.g. 42 | format bits returns 00101010
  • format number
Edit this page on GitHub
Contributors: NotTheDr01ds, fdncred
Prev
Boolean
Next
Float