瀏覽代碼

Document behavior of modulo operator (#9358)

Different languages and contexts have different default behaviors for modulo
where one or both operands are negative. "The remainder of an integer division"
is underspecified. As such, clarification is in order.

Co-authored-by: Aaron Franke <[email protected]>
Co-authored-by: Hugo Locurcio <[email protected]>
Qwertystop 1 年之前
父節點
當前提交
8d1bff6aea
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      tutorials/scripting/evaluating_expressions.rst

+ 2 - 1
tutorials/scripting/evaluating_expressions.rst

@@ -44,7 +44,8 @@ The following operators are available:
 | Division (``/``)       | Performs and integer division if both operands are integers.                        |
 | Division (``/``)       | Performs and integer division if both operands are integers.                        |
 |                        | If at least one of them is a floating-point number, returns a floating-point value. |
 |                        | If at least one of them is a floating-point number, returns a floating-point value. |
 +------------------------+-------------------------------------------------------------------------------------+
 +------------------------+-------------------------------------------------------------------------------------+
-| Modulo (``%``)         | Returns the remainder of an integer division.                                       |
+| Remainder (``%``)      | Returns the remainder of an integer division (modulo).                              |
+|                        | The result will always have the sign of the dividend.                               |
 +------------------------+-------------------------------------------------------------------------------------+
 +------------------------+-------------------------------------------------------------------------------------+
 
 
 Spaces around operators are optional. Also, keep in mind the usual
 Spaces around operators are optional. Also, keep in mind the usual