diff options
Diffstat (limited to 'Doc/Zsh/arith.yo')
-rw-r--r-- | Doc/Zsh/arith.yo | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo index 96dc2dc68..5c334ce9c 100644 --- a/Doc/Zsh/arith.yo +++ b/Doc/Zsh/arith.yo @@ -39,7 +39,8 @@ zero status. cindex(arithmetic base) cindex(bases, in arithmetic) Integers can be in bases other than 10. -A leading `tt(0x)' or `tt(0X)' denotes hexadecimal. +A leading `tt(0x)' or `tt(0X)' denotes hexadecimal and a leading +`tt(0b)' or `tt(0B) binary. Integers may also be of the form `var(base)tt(#)var(n)', where var(base) is a decimal number between two and thirty-six representing the arithmetic base and var(n) @@ -232,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. |