From 3db4f385255cc1a576885baf9bd9b8b29559e07f Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 3 Jul 2017 21:35:40 +0100 Subject: [PATCH] Explain sign of arg1/arg2 --- EIPS/eip-145.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/EIPS/eip-145.md b/EIPS/eip-145.md index cd1bf8c19d3a61..5dc4e9427da51c 100644 --- a/EIPS/eip-145.md +++ b/EIPS/eip-145.md @@ -33,6 +33,8 @@ The `SHL` instruction (shift left) pops 2 values from the stack, `arg1` and `arg (arg1 * 2^arg2) mod 2^256 ``` +where both `arg1` and `arg2` are considered as unsigned numbers. + Notes: - The shift amount (`arg2`) is interpreted as an unsigned number. - If the shift amount (`arg2`) is greater or equal 256 the result is 0. @@ -45,6 +47,8 @@ The `SHR` instruction (logical shift right) pops 2 values from the stack, `arg1` floor(arg1 / 2^arg2) ``` +Where both `arg1` and `arg2` are considered as unsigned numbers. + Notes: - The shift amount (`arg2`) is interpreted as an unsigned number. - If the shift amount (`arg2`) is greater or equal 256 the result is 0. @@ -57,6 +61,8 @@ The `SAR` instruction (arithmetic shift right) pops 2 values from the stack, `ar floor(arg1 / 2^arg2) ``` +where `arg1` is considered as a signed number and `arg2` as an unsigned number. + Notes: - The shift amount (`arg2`) is interpreted as an unsigned number. - If the shift amount (`arg2`) is greater or equal 256 the result is 0 if `arg1` is non-negative or -1 if `arg1` is negative.