diff options
author | alandonovan <adonovan@google.com> | 2021-01-19 17:43:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-19 17:43:35 -0500 |
commit | fb04d37e5d7fe9cdcc59adfcfd94d1863ac6cb38 (patch) | |
tree | d796c40466bf0c253dea495adc0595b707da3829 | |
parent | 73f535f109ef395b6b65c1161f74bc5ae9e6ae92 (diff) | |
download | starlark-go-fb04d37e5d7fe9cdcc59adfcfd94d1863ac6cb38.tar.gz |
doc/spec.md: fix mistake regarding sign of x % y (#339)
See https://github.com/bazelbuild/starlark/issues/148
for change to Starlark spec.
Updates https://github.com/bazelbuild/starlark/issues/148
-rw-r--r-- | doc/spec.md | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/doc/spec.md b/doc/spec.md index 0460285..15be009 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -545,7 +545,7 @@ The `*` operator performs multiplication. The `//` and `%` operations on integers compute floored division and remainder of floored division, respectively. If the signs of the operands differ, the sign of the remainder `x % y` -matches that of the dividend, `x`. +matches that of the divisor, `y`. For all finite x and y (y ≠ 0), `(x // y) * y + (x % y) == x`. The `/` operator implements real division, and yields a `float` result even when its operands are both of type `int`. @@ -591,6 +591,11 @@ integer value not greater than `x / y`. Although the resulting number is integral, it is represented as a `float` if either operand is a `float`. +The `%` operation computes the remainder of floored division. +As with the corresponding operation on integers, +if the signs of the operands differ, the sign of the remainder `x % y` +matches that of the divisor, `y`. + The infinite float values `+Inf` and `-Inf` represent numbers greater/less than all finite float values. |