On Fri, 09 Jan 2015 11:46:44 -0800
jdh <dhenman@xxxxxxxxx> wrote:
I believe I read that math expression evaluation will convert all
calculations in an expression if "any" value in that expression is a
real value.
This isn't the case and wherever this came from needs correcting.
Please instead read the documentation under ARITHMETIC EVALUATION in the
zshmisc manual for what actually happens and let us if know if you think
that is inadequate. The actually phrasing is "Promotion of integer to
floating point values is performed where necessary". It also refers
above that to C --- there's an underlying assumption here that the user
has some idea of the operation of C-like languages, which might of
course not be the case. "Where necessary" is in general where an
operator has a floating point number as one argument and an integer as
another; a C programmer would recognise the use of the word "promotion"
as implying this, a general user probably not. So the wording could
probably be improved. Brief and to the point suggestions on this from
anyone are welcome (long rambles on why anyone doesn't understand it
may be invigorating for the rambler but are less useful to us as
developers :-)).
See also the following shell option:
FORCE_FLOAT
Constants in arithmetic evaluation will be treated as floating
point even without the use of a decimal point. Integers in any
base will be converted.
This is most useful in zcalc, which actually has an option for this.
If the option `-f' is set, all numbers are treated as floating
point, hence for example the expression `3/4' evaluates to 0.75
rather than 0. Options must appear in separate words.
pws