[13/24] incubator-freemarker git commit: Manual: Documented % operator weirdness
Manual: Documented % operator weirdness Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/3ccd9e4c Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/3ccd9e4c Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/3ccd9e4c Branch: refs/heads/2.3 Commit: 3ccd9e4cfcfd13e4b392a7d9a8ef1f669fef649e Parents: ed65316 Author: ddekanyAuthored: Thu Oct 13 22:28:00 2016 +0200 Committer: ddekany Committed: Thu Oct 13 22:28:00 2016 +0200 -- src/manual/en_US/book.xml | 25 ++--- 1 file changed, 22 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3ccd9e4c/src/manual/en_US/book.xml -- diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml index ce9b08f..38741d3 100644 --- a/src/manual/en_US/book.xml +++ b/src/manual/en_US/book.xml @@ -3286,7 +3286,8 @@ Slicing with right-unlimited ranges: - Modulus (remainder): % + Modulus (remainder) of integer operands: + % @@ -3323,8 +3324,6 @@ ${12 % 10} ${3 + "5"} - will output this: - 35 Generally, FreeMarker never converts a string to a number @@ -3353,6 +3352,26 @@ ${-1.999?int} 1 -1 -1 + + Due to historical reasons, the % operator + works by first truncating the operands to an integer number, and + then returning the remainder of the division: + + ${12 % 5} #-- Prints 2 -- +${12.9 % 5} #-- Prints 2 -- +${12.1 % 5} #-- Prints 2 -- + +${12 % 6} #-- Prints 0 -- +${12 % 6.9} #-- Prints 0 -- + + The sign of the result of % is the same as + the sign of the left hand operand, and its absolute value is the + same as if both operands where positive: + + ${-12 % -5} #-- Prints -2 -- +${-12 % 5} #-- Prints -2 -- +${12 % -5} #-- Prints 2 -- +
incubator-freemarker git commit: Manual: Documented % operator weirdness
Repository: incubator-freemarker Updated Branches: refs/heads/2.3-gae ed6531689 -> 3ccd9e4cf Manual: Documented % operator weirdness Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/3ccd9e4c Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/3ccd9e4c Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/3ccd9e4c Branch: refs/heads/2.3-gae Commit: 3ccd9e4cfcfd13e4b392a7d9a8ef1f669fef649e Parents: ed65316 Author: ddekanyAuthored: Thu Oct 13 22:28:00 2016 +0200 Committer: ddekany Committed: Thu Oct 13 22:28:00 2016 +0200 -- src/manual/en_US/book.xml | 25 ++--- 1 file changed, 22 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/3ccd9e4c/src/manual/en_US/book.xml -- diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml index ce9b08f..38741d3 100644 --- a/src/manual/en_US/book.xml +++ b/src/manual/en_US/book.xml @@ -3286,7 +3286,8 @@ Slicing with right-unlimited ranges: - Modulus (remainder): % + Modulus (remainder) of integer operands: + % @@ -3323,8 +3324,6 @@ ${12 % 10} ${3 + "5"} - will output this: - 35 Generally, FreeMarker never converts a string to a number @@ -3353,6 +3352,26 @@ ${-1.999?int} 1 -1 -1 + + Due to historical reasons, the % operator + works by first truncating the operands to an integer number, and + then returning the remainder of the division: + + ${12 % 5} #-- Prints 2 -- +${12.9 % 5} #-- Prints 2 -- +${12.1 % 5} #-- Prints 2 -- + +${12 % 6} #-- Prints 0 -- +${12 % 6.9} #-- Prints 0 -- + + The sign of the result of % is the same as + the sign of the left hand operand, and its absolute value is the + same as if both operands where positive: + + ${-12 % -5} #-- Prints -2 -- +${-12 % 5} #-- Prints -2 -- +${12 % -5} #-- Prints 2 -- +