about summary refs log tree commit diff
path: root/Doc/Zsh/arith.yo
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2000-05-19 18:22:50 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2000-05-19 18:22:50 +0000
commit8d17d2f02dfa2b0bb4c19efcf52854fbb7fa19e5 (patch)
tree65bf9ac762900c25f7aa4b7ea88123bd6517254d /Doc/Zsh/arith.yo
parente20600c8a404d35bd4b4c02976ce08f5b166f415 (diff)
downloadzsh-8d17d2f02dfa2b0bb4c19efcf52854fbb7fa19e5.tar.gz
zsh-8d17d2f02dfa2b0bb4c19efcf52854fbb7fa19e5.tar.xz
zsh-8d17d2f02dfa2b0bb4c19efcf52854fbb7fa19e5.zip
11467: [#<base>] syntax for output base
zsh-users/3071: compdump tweak to avoid // in path
Diffstat (limited to 'Doc/Zsh/arith.yo')
-rw-r--r--Doc/Zsh/arith.yo22
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo
index e47c0284a..095756667 100644
--- a/Doc/Zsh/arith.yo
+++ b/Doc/Zsh/arith.yo
@@ -43,6 +43,28 @@ The var(base)tt(#) may also be omitted, in which case
 base 10 is used.  For backwards compatibility the form
 `tt([)var(base)tt(])var(n)' is also accepted.
 
+It is also possible to specify a base to be used for output in the form
+`tt([#)var(base)tt(])', for example `tt([#16])'.  This is used when
+outputting arithmetical substitutions or when assigning to scalar
+parameters, but an explicitly defined integer or floating point parameter
+will not be affected.  If an integer variable is implicitly defined by an
+arithmetic expression, any base specified in this way will be set as the
+variable's output arithmetic base as if the option `tt(-i) var(base)' to
+the tt(typeset) builtin had been used.  The expression has no precedence
+and if it occurs more than once in a mathematical expression, the last
+encountered is used.  For clarity it is recommended that it appear at the
+beginning of an expression.  As an example:
+
+example(typeset -i 16 y
+print $(( [#8] x = 32, y = 32 ))
+print $x $y)
+
+outputs first `tt(8#40)', the rightmost value in the given output base, and
+then `tt(8#40 16#20)', because tt(y) has been explicitly declared to
+have output base 16, while tt(x) (assuming it does not already exist) is
+implicitly typed by the arithmetic evaluation, where it acquires the output
+base 8.
+
 Floating point constants are recognized by the presence of a decimal point
 or an exponent.  The decimal point may be the first character of the
 constant, but the exponent character tt(e) or tt(E) may not, as it will be