diff options
author | chriseth <c@ethdev.com> | 2016-03-12 00:27:16 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-03-12 00:27:16 +0800 |
commit | 60a21c6487743578af6fd4e1540a36a2b80fcac7 (patch) | |
tree | 4d00233bc513da47c85c3bda44cf90ce5d0a0b75 | |
parent | 172beaec5e3c3b86926d0b710af9861b4b00c5eb (diff) | |
parent | 62d8be9e215a3740e4ac5875fe3040395ef17a0c (diff) | |
download | dexon-solidity-60a21c6487743578af6fd4e1540a36a2b80fcac7.tar dexon-solidity-60a21c6487743578af6fd4e1540a36a2b80fcac7.tar.gz dexon-solidity-60a21c6487743578af6fd4e1540a36a2b80fcac7.tar.bz2 dexon-solidity-60a21c6487743578af6fd4e1540a36a2b80fcac7.tar.lz dexon-solidity-60a21c6487743578af6fd4e1540a36a2b80fcac7.tar.xz dexon-solidity-60a21c6487743578af6fd4e1540a36a2b80fcac7.tar.zst dexon-solidity-60a21c6487743578af6fd4e1540a36a2b80fcac7.zip |
Merge pull request #427 from chriseth/intlit
Warning about using integer literals in division.
-rw-r--r-- | docs/types.rst | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/types.rst b/docs/types.rst index ad8784b7..a09a490d 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -51,6 +51,9 @@ Operators: * Bit operators: `&`, `|`, `^` (bitwise exclusive or), `~` (bitwise negation) * Arithmetic operators: `+`, `-`, unary `-`, unary `+`, `*`, `/`, `%` (remainder), `**` (exponentiation) +Division always truncates (it just maps to the DIV opcode of the EVM), but it does not truncate if both +operators are :ref:`literals<integer_literals>` (or literal expressions). + .. index:: address, balance, send, call, callcode Address @@ -132,6 +135,8 @@ number of bytes, always use one of `bytes1` to `bytes32` because they are much c .. index:: literal, literal;integer +.. _integer_literals: + Integer Literals ----------------- @@ -139,6 +144,10 @@ Integer Literals are arbitrary precision integers until they are used together w It is even possible to temporarily exceed the maximum of 256 bits as long as only integer literals are used for the computation: `var x = (0xffffffffffffffffffff * 0xffffffffffffffffffff) * 0;` Here, `x` will have the value `0` and thus the type `uint8`. +.. warning:: + Divison on integer literals used to truncate in earlier versions, but it will actually convert into a rational number in the future, i.e. `1/2` is not equal to `0`, but to `0.5`. + + .. index:: literal, literal;string, string String Literals |