Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: return status of the 'let' builtin
On Sun 5 Apr 2026, at 19:13, Jun T wrote:
> Floating point exceptions are ignored for a long time and making them
> errors would surprise some users. Instead, I would like to explicitly
> note in man page that FPEs are ignored.
looking at the documentation i realised that we don't mention NaN/Inf
support at all. here's something for that
ps: is it desirable that `typeset -p` uses different capitalisation
('nan') from the normal float conversion ('NaN')? workers/42369 seemed
to suggest not. would it be too risky to make them match now?
pps: that same thread suggests that at one point these values were
displayed with a trailing dot, as in `inf.`. i guess some people didn't
care for that, but it feels like *requiring* the dot would have been a
clean way to distinguish them from parameter names. oh well
dana
diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo
index 9f5298821..b1be4479b 100644
--- a/Doc/Zsh/arith.yo
+++ b/Doc/Zsh/arith.yo
@@ -120,6 +120,23 @@ taken for a parameter name. All numeric parts (before and after the
decimal point and in the exponent) may contain underscores after the
leading digit for visual guidance; these are ignored in computation.
+The special floating point values NaN (not a number) and infinity are
+fully supported in floating point arithmetic. They may be produced by
+certain operations, such as division by zero, or referenced explicitly in
+arithmetic constructs and float assignments using the case-insensitive
+constants tt(NaN) and tt(Inf). Expansion syntax must be used to
+reference a parameter with one of these names in these contexts:
+
+example(% nan=123 INF=456
+% print $LPAR()LPAR() nan RPAR()RPAR() $LPAR()LPAR() INF RPAR()RPAR()
+NaN Inf
+% print $LPAR()LPAR() $nan RPAR()RPAR() $LPAR()LPAR() $INF RPAR()RPAR()
+123 456
+% typeset -F f=nan && typeset -p f
+typeset -F f=nan
+% typeset -F f=$nan && typeset -p f
+typeset -F f=123.0000000000)
+
cindex(arithmetic operators)
cindex(operators, arithmetic)
An arithmetic expression uses nearly the same syntax and
Messages sorted by:
Reverse Date,
Date,
Thread,
Author