Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Float (Floating-Point Atom)

Definition

Float Float

Fields

FieldTypeDescription
contentsFloatDouble-precision floating-point number

Note

Nix itself does not have native floating-point literals. The Float atom exists in the AST but is not directly exposed in Nix source syntax. Floating-point numbers in Nix are typically represented as strings or rationals.

In nix-ast JSON AST, Float atoms appear wrapped in Constant:

{
  "tag": "Constant",
  "contents": { "tag": "Float", "contents": 3.14 }
}
  • Constant: wrapper for atoms in expressions

Nix Library Access

syntax.mkFloat 3.14
syntax.mkConstant (syntax.mkFloat 3.14)