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

Float

Description:Numbers with some fractional component
Annotation:float
Literal syntax:A decimal numeric value including a decimal place. E.g., 1.5, 2.0, -15.333
Casts:into float
See also:Types of Data - Floats

Additional language notes

  • Floats are internally represented as IEEE-754 floats with 64 bit precision.

  • Scientific notation is supported in literals, e.g. 1e3 or 1.5e-3.

  • A float is always displayed with a decimal point, even when it has no fractional part. The / operator always returns a float, even when both operands are integers (use // for integer division).

  • Floats and integers can be compared with each other.

    10 / 2
    # => 5.0
    1e3
    # => 1000.0
    0.1 + 0.2
    # => 0.30000000000000004
    2.0 == 2
    # => true
  • into int truncates the fractional part. Use math round, math floor or math ceil to round instead.

Edit this page on GitHub
Contributors: NotTheDr01ds, fdncred, yo-goto, wahidrizka
Prev
Integer
Next
Filesize