aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenton Liu <liu.denton+github@gmail.com>2016-08-26 02:19:35 +0800
committerDenton Liu <liu.denton+github@gmail.com>2016-08-27 05:13:45 +0800
commit9ace0ca310b4ed21090d06ad621f5b9c80f8a272 (patch)
treeafebe4916198da05bb10d89d1fa5a5439e93c9a7
parentf125b2813e88fbe45a27b086f654880195534f18 (diff)
downloaddexon-solidity-9ace0ca310b4ed21090d06ad621f5b9c80f8a272.tar
dexon-solidity-9ace0ca310b4ed21090d06ad621f5b9c80f8a272.tar.gz
dexon-solidity-9ace0ca310b4ed21090d06ad621f5b9c80f8a272.tar.bz2
dexon-solidity-9ace0ca310b4ed21090d06ad621f5b9c80f8a272.tar.lz
dexon-solidity-9ace0ca310b4ed21090d06ad621f5b9c80f8a272.tar.xz
dexon-solidity-9ace0ca310b4ed21090d06ad621f5b9c80f8a272.tar.zst
dexon-solidity-9ace0ca310b4ed21090d06ad621f5b9c80f8a272.zip
Clarify typecasting
-rw-r--r--docs/types.rst9
1 files changed, 7 insertions, 2 deletions
diff --git a/docs/types.rst b/docs/types.rst
index d6445ed9..737fbe7d 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -661,13 +661,18 @@ Explicit Conversions
--------------------
If the compiler does not allow implicit conversion but you know what you are
-doing, an explicit type conversion is sometimes possible::
+doing, an explicit type conversion is sometimes possible. Note that this may
+give you some unexpected behaviour so be sure to test to ensure that the
+result is what you want! Take the following example where you are converting
+a negative ``int8`` to a ``uint``:
+
+::
int8 y = -3;
uint x = uint(y);
At the end of this code snippet, ``x`` will have the value ``0xfffff..fd`` (64 hex
-characters), which is -3 in two's complement representation of 256 bits.
+characters), which is -3 in the two's complement representation of 256 bits.
If a type is explicitly converted to a smaller type, higher-order bits are
cut off::