1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-17 00:31:09 +02:00

34914: explanation of effect of integer promotion

This commit is contained in:
Peter Stephenson 2015-01-09 22:46:42 +00:00
parent 3495dc5c27
commit 53e3d9e063
2 changed files with 12 additions and 0 deletions

View file

@ -13,6 +13,9 @@
2015-01-09 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 34194: Doc/Zsh/arith.yo: add paragraph about integer
promotion.
* 34189: Src/Zle/compcore.c, Src/Zle/compctl.c,
Src/Zle/textobjects.c, Src/Zle/zle_tricky.c, Src/builtin.c,
Src/context.c, Src/exec.c, Src/hist.c, Src/init.c, Src/lex.c,

View file

@ -233,6 +233,15 @@ necessary. In addition, if any operator which requires an integer
equivalents with assignment) is given a floating point argument, it will be
silently rounded down to the next integer.
Users should beware that, in common with many other programming
languages but not software designed for calculation, the evaluation of
an expression in zsh is taken a term at a time and promotion of integers
to floating point does not occur in terms only containing integers. A
typical result of this is that a division such as tt(6/8) is truncated,
in this being rounded down to 0. The tt(FORCE_FLOAT) shell option can
be used in scripts or functions where floating point evaluation is
required throughout.
Scalar variables can hold integer or floating point values at different
times; there is no memory of the numeric type in this case.