[go: up one dir, main page]

Bitwise operation: Difference between revisions

Content deleted Content added
CoolOppo (talk | contribs)
m OR: Simplified frasing
Line 163:
<source lang="c">x = y << 2;</source>
 
assigns ''x'' the result of shifting ''y'' to the left by two bits, which is equivalent with multiplication with 4.
 
In C, the result of right-shifting a negative value is implementation-defined, and the result of left-shifting a signed value is undefined if the result cannot be represented in the result type.<ref>[http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.htm JTC1/SC22/WG14 N843 "C programming language"], section 6.5.7</ref> In C#, the right-shift is an arithmetic shift when the first operand is an int or long. If the first operand is of type uint or ulong, the right-shift is a logical shift.<ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/xt18et0d%28v=vs.110%29.aspx|title=Operator (C# Reference)|accessdate=14 July 2013|publisher=Microsoft}}</ref>