diff options
Diffstat (limited to 'docs/types.rst')
-rw-r--r-- | docs/types.rst | 9 |
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:: |