summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2001-10-06 17:40:26 +0000
committerClint Adams <clint@users.sourceforge.net>2001-10-06 17:40:26 +0000
commit7668a03cb291f64ecfe89cdb65d070fb68eaff2d (patch)
treeda68a29fb20cae18caba64b6d0d3678397e3c085
parent15941: complete reiserfs mount options. (diff)
downloadzsh-7668a03cb291f64ecfe89cdb65d070fb68eaff2d.tar
zsh-7668a03cb291f64ecfe89cdb65d070fb68eaff2d.tar.gz
zsh-7668a03cb291f64ecfe89cdb65d070fb68eaff2d.tar.bz2
zsh-7668a03cb291f64ecfe89cdb65d070fb68eaff2d.tar.lz
zsh-7668a03cb291f64ecfe89cdb65d070fb68eaff2d.tar.xz
zsh-7668a03cb291f64ecfe89cdb65d070fb68eaff2d.tar.zst
zsh-7668a03cb291f64ecfe89cdb65d070fb68eaff2d.zip
Norbert Koch: 15954: fix inconsistency of variable name in example.
-rw-r--r--ChangeLog5
-rw-r--r--Doc/Zsh/arith.yo39
2 files changed, 39 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index eabb05654..d9556a357 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-10-06 Clint Adams <clint@zsh.org>
+
+ * Norbert Koch: 15954: Doc/Zsh/arith.yo:
+ fix inconsistency of variable name in example.
+
2001-10-05 Clint Adams <clint@zsh.org>
* 15941: Completion/Unix/Command/_mount:
diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo
index 29897a233..4ff1b6ce7 100644
--- a/Doc/Zsh/arith.yo
+++ b/Doc/Zsh/arith.yo
@@ -29,7 +29,7 @@ is equivalent to
example(let "val = 2 + 1")
-both assigning the value 3 to the shell variable tt(foo) and returning a
+both assigning the value 3 to the shell variable tt(var) and returning a
zero status.
cindex(bases, in arithmetic)
@@ -43,6 +43,33 @@ 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.
+
+When an output base is specified using the `tt([#)var(base)tt(])' syntax,
+an appropriate base prefix will be output if necessary, so that the value
+output is valid syntax for input. If the tt(#) is doubled, for example
+`tt([##16])', then no base prefix is output.
+
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
@@ -84,12 +111,14 @@ Mathematical functions can be called with the syntax
`var(func)tt(LPAR())var(args)tt(RPAR())', where the function decides
if the var(args) is used as a string or a comma-separated list of
arithmetic expressions. The shell currently defines no mathematical
-functions, but modules may define some.
+functions by default, but the module tt(zsh/mathfunc) may be loaded with
+the tt(zmodload) builtin to provide standard floating point mathematical
+functions.
An expression of the form `tt(##)var(x)' where var(x) is any character
-sequence such as `tt(a)', `tt(^A)', or `tt(\M-\C-x)' gives the ascii
+sequence such as `tt(a)', `tt(^A)', or `tt(\M-\C-x)' gives the ASCII
value of this character and an expression of the form `tt(#)var(foo)'
-gives the ascii value of the first character of the value of the
+gives the ASCII value of the first character of the value of the
parameter var(foo). Note that this is different from the expression
`tt($#)var(foo)', a standard parameter substitution which gives the
length of the parameter var(foo). `tt(#\)' is accepted instead of
@@ -139,7 +168,7 @@ retain that type either until the type is explicitly changed or until the
end of the scope. This can have unforeseen consequences. For example, in
the loop
-example(for (( f = 0; f < 1; f += 0.1 )); do;
+example(for (( f = 0; f < 1; f += 0.1 )); do
# use $f
done)