mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 13:01:28 +02:00
34290: note FORCE_FLOAT option change
This commit is contained in:
parent
3a99ef322d
commit
2b8b1a49d5
2 changed files with 47 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
||||||
2015-01-15 Peter Stephenson <p.stephenson@samsung.com>
|
2015-01-15 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
|
* 34290 (correcting typo): README: note FORCE_FLOAT behaviour change.
|
||||||
|
|
||||||
* 34280: Doc/Zsh/options.yo, Src/math.c, Test/C01arith.ztst:
|
* 34280: Doc/Zsh/options.yo, Src/math.c, Test/C01arith.ztst:
|
||||||
make FORCE_FLOAT option also cover variables when read for
|
make FORCE_FLOAT option also cover variables when read for
|
||||||
use in arithmetic expressions.
|
use in arithmetic expressions.
|
||||||
|
|
49
README
49
README
|
@ -38,10 +38,12 @@ details, see the documentation.
|
||||||
Incompatibilites between 5.0.7 and 5.0.8
|
Incompatibilites between 5.0.7 and 5.0.8
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
A couple of arithmetic operations have changed: the new behaviour
|
Various arithmetic operations have changed, in particular with respect
|
||||||
is intended to be more consistent, but is not compatible with the old.
|
to the choice of integer or floating point operations. The new
|
||||||
|
behaviour is intended to be more consistent, but is not compatible with
|
||||||
|
the old.
|
||||||
|
|
||||||
Previously, the modulus operation, `%', implicitly converted the
|
1) Previously, the modulus operation, `%', implicitly converted the
|
||||||
operation to integer and output an integer result, even if one
|
operation to integer and output an integer result, even if one
|
||||||
or both of the arguments were floating point. Now, the C math
|
or both of the arguments were floating point. Now, the C math
|
||||||
library fmod() operator is used to implement the operation where
|
library fmod() operator is used to implement the operation where
|
||||||
|
@ -57,7 +59,8 @@ New behaviour:
|
||||||
% print $(( 5.5 % 2 ))
|
% print $(( 5.5 % 2 ))
|
||||||
1.5
|
1.5
|
||||||
|
|
||||||
Previously, assignments to variables assigned the correct type to
|
|
||||||
|
2) Previously, assignments to variables assigned the correct type to
|
||||||
variables declared as floating point or integer, but this type was
|
variables declared as floating point or integer, but this type was
|
||||||
not propagated to the value of the expression, as a C programmer
|
not propagated to the value of the expression, as a C programmer
|
||||||
would naturally expect. Now, the type of the variable is propagated
|
would naturally expect. Now, the type of the variable is propagated
|
||||||
|
@ -81,6 +84,44 @@ New behaviour:
|
||||||
% print $var
|
% print $var
|
||||||
2
|
2
|
||||||
|
|
||||||
|
|
||||||
|
3) Previously, the FORCE_FLOAT option only forced the use of floating
|
||||||
|
point in arithmetic expressions for integer constants, i.e. numbers
|
||||||
|
typed directly into the expression, but not for variables. Hence
|
||||||
|
an operation involving only integer variables (or string variables
|
||||||
|
containing integers) was not forced to be performed with floating point
|
||||||
|
arithmetic. Now, operations involving variables are also forced to
|
||||||
|
floating point. For example:
|
||||||
|
|
||||||
|
Old behaviour:
|
||||||
|
|
||||||
|
% unsetopt FORCE_FLOAT
|
||||||
|
% print $(( 1 / 2 ))
|
||||||
|
0
|
||||||
|
% integer i=1 j=2
|
||||||
|
% print $(( i / j ))
|
||||||
|
0
|
||||||
|
% setopt FORCE_FLOAT
|
||||||
|
% print $(( 1 / 2 ))
|
||||||
|
0.5
|
||||||
|
% print $(( i / j ))
|
||||||
|
0
|
||||||
|
|
||||||
|
New behaviour:
|
||||||
|
|
||||||
|
% unsetopt FORCE_FLOAT
|
||||||
|
% print $(( 1 / 2 ))
|
||||||
|
0
|
||||||
|
% integer i=1 j=2
|
||||||
|
% print $(( i / j ))
|
||||||
|
0
|
||||||
|
% setopt FORCE_FLOAT
|
||||||
|
% print $(( 1 / 2 ))
|
||||||
|
0.5
|
||||||
|
% print $(( i / j ))
|
||||||
|
0.5
|
||||||
|
|
||||||
|
|
||||||
Incompatibilities between 5.0.2 and 5.0.5
|
Incompatibilities between 5.0.2 and 5.0.5
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue