float
Declare floating-point shell variables
TLDR
SYNOPSIS
float [-ghlrtux] [name[=value]...]
DESCRIPTION
float is a zsh builtin command that declares variables with the floating-point attribute. It is equivalent to typeset -E, causing the variable to be stored and displayed in floating-point (scientific) notation.When a value is assigned to a float variable, zsh performs arithmetic evaluation, allowing expressions like `float x=1.0/3.0`. The result is stored as a double-precision floating-point number. Variables declared with float display in scientific notation by default (e.g., `3.1400000000000000e+00`).Without arguments, float lists all currently declared floating-point variables and their values.
PARAMETERS
-g
Create global variable when used inside a function-h
Hide variable; do not export to child processes even if exported in outer scope-l
Left-justify and strip leading blanks-r
Make variable read-only-t
Tag the variable (user-defined attribute)-u
Force uppercase on assignment (for string context)-x
Export variable to environment of child processes+attr
Remove the specified attribute
CAVEATS
Only available in zsh; not a builtin in bash or other POSIX shells. Floating-point arithmetic is subject to the usual IEEE 754 precision limitations and rounding errors. Read-only float variables cannot be unset or modified.
HISTORY
The float builtin was introduced in zsh as a convenience shorthand for typeset -E. Zsh has supported floating-point arithmetic since version 4.0 (2001), part of its extended mathematical capabilities beyond what POSIX sh requires. The float, integer, and readonly builtins in zsh all serve as specialized wrappers around typeset.
