Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Math expression evaluation error?
- X-seq: zsh-workers 34187
- From: jdh <dhenman@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Math expression evaluation error?
- Date: Fri, 09 Jan 2015 11:46:44 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=smhbVACxnfG2jXUnSmepG65TCYllB5FfaVZ5PC1qSho=; b=WhHky05dTSgHzHJ+0ALQA1mAXQUSmB96KY7qEfmCHcxLWLL2e7z+ltgE7M4N2IwYwi uMW1hZ7s0tSELnXrQ2qS3XXwFHF3JIF+MY9/jdxzQUE6Jeo7tt4ZsGu+aems/Er9gpc1 S2vHlIxd5KVd1rdJGBPIFdadvB5NpYKl5LE/6AX3lBgbLN3RYlO5YmuM1vwg7RDbvR+P KEyuTqEgRc1JRLcXvaCWg/4mvZ5Ndo3UHkqZTj/wU4XkY0TV2izK8NXSSxO1w0IYy0B5 /hwyPBXQuT5b7AA7TQK0BtCO2F7SAXfdItsNKhIa3HV6xhjF3LPVUIgfbS4bytvbLzXH TVng==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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.
That is not true if the word "any" is true or a bug has crawled into the
numeric expression evaluator. Or I read wrong..
Example on my system, zsh 5.0.7 (i686-pc-linux-gnu), I get the following
results for the shown example:
$ echo $(( 6+3/8. + 10 + 5/8. )) $(( 6+3/8 + 10 + 5/8. ))
17. 16.625
In the above case only the second term which contains a real number is
evaluated as real , the previous term is taken as integer and decimal
values are truncated (non-existent. This same behavior is demonstrated
in zcalc. Probably uses the same logic.
Though I understand why this happens (or think I do). It could cause
someone a major mistake if they are unaware of this and rely on the outcome.
Regards
Darel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author