Last active
December 19, 2015 07:58
-
-
Save gerdr/5922055 to your computer and use it in GitHub Desktop.
shift semantics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rakudo/Parrot, int and (soon) Int: | |
17 +> 3 = 2 # 17 div 2**3 | |
-17 +> 3 = -3 # floor(-17 / 2**3) | |
17 +> -3 = 136 # 17 <+ 3 = 17 * 2**3 | |
-17 +> -3 = -136 # -17 <+ 3 = -17 * 2**3 | |
17 +< 3 = 136 # 17 * 2**3 | |
-17 +< 3 = -136 # -17 * 2**3 | |
17 +< -3 = 2 # 17 +> 3 = 17 div 2**3 | |
-17 +< -3 = -3 # -17 +> 3 = floor(-17 / 2**3) | |
Niecza (via C#), Java: | |
17 +> 3 = 2 # 17 div 2**3 | |
-17 +> 3 = -3 # floor(-17 / 2**3) | |
17 +> -3 = 0 # 17 +> (32 - 3) = 17 div 2**(32 - 3) | |
-17 +> -3 = -1 # -17 +> (32 - 3) = floor(-17 / 2**(32 - 3)) | |
17 +< 3 = 136 # 17 * 2**3 | |
-17 +< 3 = -136 # -17 * 2**3 | |
17 +< -3 = 536870912 # 17 +< (32 - 3) = (17 * 2**(32 - 3)) mod 2**32 | |
-17 +< -3 = -536870912 # -17 +< (32 - 3) = (-17 * 2**(32 - 3)) mod 2**32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment