From fc3f40febe3ed7686682e2e9ef4f615b206400b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 28 Apr 2017 14:00:59 +0200 Subject: [PATCH] Add warning about SAR in docs --- docs/types.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/types.rst b/docs/types.rst index 60235ad26..c868adc64 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -64,6 +64,12 @@ expression ``x << y`` is equivalent to ``x * 2**y`` and ``x >> y`` is equivalent to ``x / 2**y``. This means that shifting negative numbers sign extends. Shifting by a negative amount throws a runtime exception. +.. warning:: + The results produced by shift right of negative values of signed integer types is different from those produced + by other programming languages. In Solidity, shift right maps to division so the shifted negative values + are going to be rounded towards zero (truncated). In other programming languages the shift right of negative values + works like division with rounding down (towards negative infinity). + .. index:: address, balance, send, call, callcode, delegatecall, transfer .. _address: