Skip to content

Commit

Permalink
doc/spec.md: fix mistake regarding sign of x % y (google#339)
Browse files Browse the repository at this point in the history
See bazelbuild/starlark#148
for change to Starlark spec.

Updates bazelbuild/starlark#148
  • Loading branch information
adonovan authored Jan 19, 2021
1 parent 73f535f commit fb04d37
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion doc/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit fb04d37

Please sign in to comment.