mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixed code example which utilizes non-existing function 'abs' - the value is stated to be negative so abs(a) is the same as -a
This commit is contained in:
parent
2d601a4f23
commit
b7e6dc3d05
@ -110,7 +110,7 @@ Modulo
|
|||||||
|
|
||||||
The modulo operation ``a % n`` yields the remainder ``r`` after the division of the operand ``a``
|
The modulo operation ``a % n`` yields the remainder ``r`` after the division of the operand ``a``
|
||||||
by the operand ``n``, where ``q = int(a / n)`` and ``r = a - (n * q)``. This means that modulo
|
by the operand ``n``, where ``q = int(a / n)`` and ``r = a - (n * q)``. This means that modulo
|
||||||
results in the same sign as its left operand (or zero) and ``a % n == -(abs(a) % n)`` holds for negative ``a``:
|
results in the same sign as its left operand (or zero) and ``a % n == -(-a % n)`` holds for negative ``a``:
|
||||||
|
|
||||||
* ``int256(5) % int256(2) == int256(1)``
|
* ``int256(5) % int256(2) == int256(1)``
|
||||||
* ``int256(5) % int256(-2) == int256(1)``
|
* ``int256(5) % int256(-2) == int256(1)``
|
||||||
|
Loading…
Reference in New Issue
Block a user