<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.formulasearchengine.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=98.248.229.177</id>
	<title>formulasearchengine - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.formulasearchengine.com/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=98.248.229.177"/>
	<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/wiki/Special:Contributions/98.248.229.177"/>
	<updated>2026-08-17T19:51:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.47.0-wmf.7</generator>
	<entry>
		<id>https://en.formulasearchengine.com/w/index.php?title=Archimedean_group&amp;diff=3507</id>
		<title>Archimedean group</title>
		<link rel="alternate" type="text/html" href="https://en.formulasearchengine.com/w/index.php?title=Archimedean_group&amp;diff=3507"/>
		<updated>2012-01-05T07:04:19Z</updated>

		<summary type="html">&lt;p&gt;98.248.229.177: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{refimprove|date=August 2010}}&lt;br /&gt;
&lt;br /&gt;
In [[digital computer]] [[computer programming|programming]], a &#039;&#039;&#039;bitwise operation&#039;&#039;&#039; operates on one or more [[bit pattern]]s or [[Binary numeral system|binary numerals]] at the level of their individual [[bit]]s. It is a fast, primitive action directly supported by the [[central processing unit|processor]], and is used to manipulate values for comparisons and calculations.&lt;br /&gt;
&lt;br /&gt;
On simple low-cost processors, typically, bitwise operations are substantially faster than division, several times faster than multiplication, and sometimes significantly faster than addition. While modern processors usually perform addition and multiplication just as fast as bitwise operations due to their longer [[instruction pipeline]]s and other [[computer architecture|architectural]] design choices, bitwise operations do commonly use less power because of the reduced use of resources.&lt;br /&gt;
&lt;br /&gt;
==Bitwise operators==&lt;br /&gt;
In the explanations below, any indication of a bit&#039;s position is counted from the right (least significant) side, advancing left. For example, the binary value 0001 (decimal 1) has zeroes at every position but the first one.&lt;br /&gt;
&lt;br /&gt;
===NOT===&lt;br /&gt;
&amp;lt;!-- linked from redirects [[Bitwise complement]], [[Bit complement]], [[Bitwise NOT]] --&amp;gt;&lt;br /&gt;
The &#039;&#039;&#039;bitwise NOT&#039;&#039;&#039;, or &#039;&#039;&#039;complement&#039;&#039;&#039;, is a [[unary operation]] that performs [[negation|logical negation]] on each bit, forming the [[ones&#039; complement]] of the given binary value. Bits that are 0 become 1, and those that are 1 become 0. For example:&lt;br /&gt;
&lt;br /&gt;
 NOT 0111  (decimal 7)&lt;br /&gt;
   = 1000  (decimal 8)&lt;br /&gt;
&lt;br /&gt;
The bitwise complement is equal to the [[two&#039;s complement]] of the value minus one. If two&#039;s complement arithmetic is used, then&lt;br /&gt;
&lt;br /&gt;
:NOT &#039;&#039;x&#039;&#039; = −&#039;&#039;x&#039;&#039; − 1.&lt;br /&gt;
&lt;br /&gt;
For unsigned [[Integer_(computer_science)|integers]], the bitwise complement of a number is the &amp;quot;mirror reflection&amp;quot; of the number across the half-way point of the unsigned integer&#039;s range. For example, for 8-bit unsigned integers, &amp;lt;code&amp;gt;NOT x = 255 - x&amp;lt;/code&amp;gt;, which can be visualized on a graph as a downward line that effectively &amp;quot;flips&amp;quot; an increasing range from 0 to 255, to a decreasing range from 255 to 0. A simple but illustrative example use is to invert a grayscale image where each pixel is stored as an unsigned integer.&lt;br /&gt;
&lt;br /&gt;
===AND===&lt;br /&gt;
A &#039;&#039;&#039;bitwise AND&#039;&#039;&#039; takes two binary representations of equal length and performs the [[Logical conjunction|logical AND]] operation on each pair of corresponding bits. The result in each position is 1 if the first bit is 1 &#039;&#039;and&#039;&#039; the second bit is 1; otherwise, the result is 0. In this, we perform the multiplication of two bits; i.e., 1 × 0 = 0 and 1 × 1 = 1. For example:&lt;br /&gt;
&lt;br /&gt;
     0101 (decimal 5)&lt;br /&gt;
 AND 0011 (decimal 3)&lt;br /&gt;
   = 0001 (decimal 1)&lt;br /&gt;
&lt;br /&gt;
The operation may be used to determine whether a particular bit is &#039;&#039;set&#039;&#039; (1) or &#039;&#039;clear&#039;&#039; (0). For example, given a bit pattern 0011 (decimal 3), to determine whether the second bit is set we use a bitwise AND with a bit pattern containing 1 only in the second bit:&lt;br /&gt;
&lt;br /&gt;
     0011 (decimal 3)&lt;br /&gt;
 AND 0010 (decimal 2)&lt;br /&gt;
   = 0010 (decimal 2)&lt;br /&gt;
&lt;br /&gt;
Because the result 0010 is non-zero, we know the second bit in the original pattern was set. This is often called &#039;&#039;bit masking&#039;&#039;. (By analogy, the use of [[masking tape]] covers, or &#039;&#039;masks&#039;&#039;, portions that should not be altered or portions that are not of interest. In this case, the 0 values mask the bits that are not of interest.)&lt;br /&gt;
&lt;br /&gt;
If we store the result, this may be used to clear selected bits in a register. Given the example 0110 (decimal 6), the second bit may be cleared by using a bitwise AND with the pattern that has a zero only in the second bit:&lt;br /&gt;
&lt;br /&gt;
     0110 (decimal 6)&lt;br /&gt;
 AND 1101 (decimal 13)&lt;br /&gt;
   = 0100 (decimal 4)&lt;br /&gt;
&lt;br /&gt;
Because of this property, it becomes easy to check the parity of a binary number by checking the value of the lowest valued bit. Using the example above:&lt;br /&gt;
&lt;br /&gt;
     0110 (decimal 6)&lt;br /&gt;
 AND 0001 (decimal 1)&lt;br /&gt;
   = 0000 (decimal 0)&lt;br /&gt;
&lt;br /&gt;
Therefore 6 is divisible by two and even.&lt;br /&gt;
&lt;br /&gt;
===OR===&lt;br /&gt;
A &#039;&#039;&#039;bitwise OR&#039;&#039;&#039; takes two bit patterns of equal length and performs the [[Logical disjunction|logical inclusive OR]] operation on each pair of corresponding bits. The result in each position is 1 if the first bit is 1 &#039;&#039;or&#039;&#039; the second bit is 1 &#039;&#039;or&#039;&#039; both bits are 1; otherwise, the result is 0. For example:&lt;br /&gt;
&lt;br /&gt;
    0101 (decimal 5)&lt;br /&gt;
 OR 0011 (decimal 3)&lt;br /&gt;
  = 0111 (decimal 7)&lt;br /&gt;
&lt;br /&gt;
The bitwise OR may be used to set selected bits, such as a specific bit (or [[Flag word|flag]]) in a register where each bit represents an individual [[Boolean data type|Boolean]] state. For example 0010 (decimal 2) can be considered a set of four flags, where the first, third, and fourth flags are clear (0) and the second flag is set (1). The fourth flag may be set by performing a bitwise OR between this value and a bit pattern with only the fourth bit set:&lt;br /&gt;
&lt;br /&gt;
    0010 (decimal 2)&lt;br /&gt;
 OR 1000 (decimal 8)&lt;br /&gt;
  = 1010 (decimal 10)&lt;br /&gt;
&lt;br /&gt;
This technique is an efficient way to store a number of Boolean values using as little memory as possible.&lt;br /&gt;
&lt;br /&gt;
===XOR===&lt;br /&gt;
A &#039;&#039;&#039;bitwise XOR&#039;&#039;&#039; takes two bit patterns of equal length and performs the [[Exclusive disjunction|logical exclusive OR]] operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 &#039;&#039;or&#039;&#039; only the second bit is 1, but will be 0 if both are 0 or both are 1. In this we perform the comparison of two bits, being 1 if the two bits are different, and 0 if they are the same. For example:&lt;br /&gt;
&lt;br /&gt;
     0101 (decimal 5)&lt;br /&gt;
 XOR 0011 (decimal 3)&lt;br /&gt;
   = 0110 (decimal 6)&lt;br /&gt;
&lt;br /&gt;
The bitwise XOR may be used to invert selected bits in a register (also called [[toggle]] or flip). Any bit may be toggled by XORing it with 1. For example, given the bit pattern 0010 (decimal 2) the second and fourth bits may be toggled by a bitwise XOR with a bit pattern containing 1 in the second and fourth positions:&lt;br /&gt;
&lt;br /&gt;
     0010 (decimal 2)&lt;br /&gt;
 XOR 1010 (decimal 10)&lt;br /&gt;
   = 1000 (decimal 8)&lt;br /&gt;
&lt;br /&gt;
This technique may be used to manipulate bit patterns representing sets of Boolean states.&lt;br /&gt;
&lt;br /&gt;
[[Assembly language]] programmers sometimes use XOR as a short-cut to setting the value of a [[Processor register|register]] to zero. Performing XOR on a value against itself always yields zero, and on many architectures this operation requires fewer clock cycles and/or memory than loading a zero value and saving it to the register.&lt;br /&gt;
&lt;br /&gt;
===Mathematical equivalents===&lt;br /&gt;
&lt;br /&gt;
Assuming {{mvar|x &amp;gt; y}}, for the non-negative integers, the bitwise operations can be written as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\text{NOT }x = \sum_{n=0}^{b}2^n\left[\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2 + 1\right) \bmod 2\right]&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;x\text{ AND }y = \sum_{n=0}^{b}2^n\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2\right)\left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;x\text{ OR }y = \sum_{n=0}^{b}2^n\left[\left[\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2\right) + \left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right) + \left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2\right)\left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right)\bmod 2\right]\bmod 2\right]&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;x\text{ XOR }y = \sum_{n=0}^{b}2^n\left[\left[\left(\left\lfloor\frac{x}{2^n}\right\rfloor \bmod 2\right) + \left(\left\lfloor\frac{y}{2^n}\right\rfloor \bmod 2\right)\right]\bmod 2\right]&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;math&amp;gt;b&amp;lt;/math&amp;gt; is the number of bits in &amp;lt;math&amp;gt;x&amp;lt;/math&amp;gt; (&amp;lt;math&amp;gt;= \lfloor\log_2 x\rfloor&amp;lt;/math&amp;gt; for all &amp;lt;math&amp;gt;x \neq 0&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
===Atomic inputs===&lt;br /&gt;
For the examples above often 3 and 5 (binary 0011 and 0101) are used as inputs. They correspond to the unchanged [[Statement (logic)|statements]] among the [[Binary operation|2-ary]] [[logical connective]]s. For the [[Ternary operation|3-ary]] case 15, 51 and 85 would be used. These numbers are found in the number triangle {{OEIS2C|A211344}}:&lt;br /&gt;
            1                                  01&lt;br /&gt;
         3     5                       0011          0101&lt;br /&gt;
     15    51     85          00001111      00110011      01010101&lt;br /&gt;
&lt;br /&gt;
==Bit shifts==&lt;br /&gt;
The &#039;&#039;&#039;bit shifts&#039;&#039;&#039; are sometimes considered bitwise operations, because they operate on the binary representation of an integer instead of its numerical value; however, the bit shifts do not operate on pairs of corresponding bits, and therefore cannot properly be called &#039;&#039;bit-wise&#039;&#039;. In these operations the digits are moved, or &#039;&#039;shifted&#039;&#039;, to the left or right. [[Processor register|Register]]s in a computer processor have a fixed width, so some bits will be &amp;quot;shifted out&amp;quot; of the register at one end, while the same number of bits are &amp;quot;shifted in&amp;quot; from the other end; the differences between bit shift operators lie in how they determine the values of the shifted-in bits.&lt;br /&gt;
&lt;br /&gt;
===Arithmetic shift===&lt;br /&gt;
{{main|Arithmetic shift}}&lt;br /&gt;
[[Image:Rotate left logically.svg|thumb|150px|Left arithmetic shift]]&lt;br /&gt;
[[Image:Rotate right arithmetically.svg|thumb|150px|Right arithmetic shift]]&lt;br /&gt;
In an &#039;&#039;arithmetic shift&#039;&#039;, the bits that are shifted out of either end are discarded. In a left arithmetic shift, zeros are shifted in on the right; in a right arithmetic shift, the [[sign bit]] is shifted in on the left, thus preserving the sign of the operand. Further on, while shifting right, the empty spaces will be filled up with a copy of the most significant bit (MSB), meaning that by shifting the second arithmetic shift register (ASR#2), with a MSB=1, you fill up with 1.&lt;br /&gt;
&lt;br /&gt;
This example uses an 8-bit register:&lt;br /&gt;
&lt;br /&gt;
    00010111 (decimal +23) LEFT-SHIFT&lt;br /&gt;
 =  00101110 (decimal +46)&lt;br /&gt;
&lt;br /&gt;
    10010111 (decimal −105) RIGHT-SHIFT&lt;br /&gt;
 =  11001011 (decimal −53)&lt;br /&gt;
&lt;br /&gt;
In the first case, the leftmost digit was shifted past the end of the register, and a new 0 was shifted into the rightmost position. In the second case, the rightmost 1 was shifted out (perhaps into the carry flag), and a new 1 was copied into the leftmost position, preserving the sign of the number. Multiple shifts are sometimes shortened to a single shift by some number of digits. For example:&lt;br /&gt;
&lt;br /&gt;
    00010111 (decimal +23) LEFT-SHIFT-BY-TWO&lt;br /&gt;
 =  01011100 (decimal +92)&lt;br /&gt;
&lt;br /&gt;
A left arithmetic shift by &#039;&#039;n&#039;&#039; is equivalent to multiplying by 2&amp;lt;sup&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sup&amp;gt; (provided the value does not [[arithmetic overflow|overflow]]), while a right arithmetic shift by &#039;&#039;n&#039;&#039; of a [[two&#039;s complement]] value is equivalent to dividing by 2&amp;lt;sup&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sup&amp;gt; and rounding toward [[negative infinity]]. If the binary number is treated as [[ones&#039; complement]], then the same right-shift operation results in division by 2&amp;lt;sup&amp;gt;&#039;&#039;n&#039;&#039;&amp;lt;/sup&amp;gt; and rounding toward zero.&lt;br /&gt;
&lt;br /&gt;
===Logical shift===&lt;br /&gt;
{{main|Logical shift}}&lt;br /&gt;
&amp;lt;!--images placed next to each other as text is currently so short--&amp;gt;&lt;br /&gt;
{| align=right border=0 cellpadding=0 cellspacing=0&lt;br /&gt;
| [[Image:Rotate left logically.svg|thumb|150px|Left logical shift]]&lt;br /&gt;
| [[Image:Rotate right logically.svg|thumb|150px|Right logical shift]]&lt;br /&gt;
|}&lt;br /&gt;
In a &#039;&#039;logical shift&#039;&#039;, zeros are shifted in to replace the discarded bits. Therefore the logical and arithmetic left-shifts are exactly the same.&lt;br /&gt;
&lt;br /&gt;
However, as the logical right-shift inserts value 0 bits into the most significant bit, instead of copying the sign bit, it is ideal for unsigned binary numbers, while the arithmetic right-shift is ideal for signed [[two&#039;s complement]] binary numbers.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Rotate no carry===&lt;br /&gt;
{{main|Circular shift}}&lt;br /&gt;
&amp;lt;!--images placed next to each other as text is currently so short--&amp;gt;&lt;br /&gt;
{| align=right border=0 cellpadding=0 cellspacing=0&lt;br /&gt;
| [[Image:Rotate left.svg|thumb|150px|Left circular shift or rotate]]&lt;br /&gt;
| [[Image:Rotate right.svg|thumb|150px|Right circular shift or rotate]]&lt;br /&gt;
|}&lt;br /&gt;
Another form of shift is the &#039;&#039;circular shift&#039;&#039; or &#039;&#039;bit rotation&#039;&#039;. In this operation, the bits are &amp;quot;rotated&amp;quot; as if the left and right ends of the register were joined. The value that is shifted in on the right during a left-shift is whatever value was shifted out on the left, and vice versa. This operation is useful if it is necessary to retain all the existing bits, and is frequently used in digital [[cryptography]].&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Rotate through carry===&lt;br /&gt;
&amp;lt;!--images placed next to each other as text is currently so short--&amp;gt;&lt;br /&gt;
{| align=right border=0 cellpadding=0 cellspacing=0&lt;br /&gt;
|[[Image:Rotate left through carry.svg|thumb|150px|Left rotate through carry]]&lt;br /&gt;
|[[Image:Rotate right through carry.svg|thumb|150px|Right rotate through carry]]&lt;br /&gt;
|}&lt;br /&gt;
&#039;&#039;Rotate through carry&#039;&#039; is similar to the &#039;&#039;rotate no carry&#039;&#039; operation, but the two ends of the register are separated by the [[carry flag]]. The bit that is shifted in (on either end) is the old value of the carry flag, and the bit that is shifted out (on the other end) becomes the new value of the carry flag.&lt;br /&gt;
&lt;br /&gt;
A single &#039;&#039;rotate through carry&#039;&#039; can simulate a logical or arithmetic shift of one position by setting up the carry flag beforehand. For example, if the carry flag contains 0, then &amp;lt;code&amp;gt;x RIGHT-ROTATE-THROUGH-CARRY-BY-ONE&amp;lt;/code&amp;gt; is a logical right-shift, and if the carry flag contains a copy of the sign bit, then &amp;lt;code&amp;gt;x RIGHT-ROTATE-THROUGH-CARRY-BY-ONE&amp;lt;/code&amp;gt; is an arithmetic right-shift. For this reason, some microcontrollers such as low end [[PIC microcontroller|PIC]]s just have &#039;&#039;rotate&#039;&#039; and &#039;&#039;rotate through carry&#039;&#039;, and don&#039;t bother with arithmetic or logical shift instructions.&lt;br /&gt;
&lt;br /&gt;
Rotate through carry is especially useful when performing shifts on numbers larger than the processor&#039;s native [[word size]], because if a large number is stored in two registers, the bit that is shifted off the end of the first register must come in at the other end of the second. With rotate-through-carry, that bit is &amp;quot;saved&amp;quot; in the carry flag during the first shift, ready to shift in during the second shift without any extra preparation.&lt;br /&gt;
&amp;lt;br clear=&amp;quot;all&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Shifts in C, C++, C#, Python===&lt;br /&gt;
In C-inspired languages, the left and right shift operators are &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;&amp;amp;lt;&amp;lt;/code&amp;gt;&amp;quot; and &amp;quot;&amp;lt;code&amp;gt;&amp;amp;gt;&amp;amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, respectively. The number of places to shift is given as the second argument to the shift operators. For example,&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;x = y &amp;lt;&amp;lt; 2;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
assigns &#039;&#039;x&#039;&#039; the result of shifting &#039;&#039;y&#039;&#039; to the left by two bits.&lt;br /&gt;
&lt;br /&gt;
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.&amp;lt;ref&amp;gt;[http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/n843.htm JTC1/SC22/WG14 N843 &amp;quot;C programming language&amp;quot;], section 6.5.7&amp;lt;/ref&amp;gt; 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.&amp;lt;ref&amp;gt;{{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}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are also compiler-specific intrinsics implementing [[circular shift]]s, like [http://msdn.microsoft.com/en-us/library/t5e2f3sc(VS.80).aspx _rotl8, _rotl16], [http://msdn.microsoft.com/en-us/library/yy0728bz(VS.80).aspx _rotr8, _rotr16] in Microsoft [[Visual C++]].&lt;br /&gt;
&lt;br /&gt;
===Shifts in Java===&lt;br /&gt;
In [[Java (programming language)|Java]], all integer types are signed, and the &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;&amp;amp;lt;&amp;lt;/code&amp;gt;&amp;quot; and &amp;quot;&amp;lt;code&amp;gt;&amp;amp;gt;&amp;amp;gt;&amp;lt;/code&amp;gt;&amp;quot; operators perform arithmetic shifts. Java adds the operator &amp;quot;&amp;lt;code&amp;gt;&amp;amp;gt;&amp;amp;gt;&amp;amp;gt;&amp;lt;/code&amp;gt;&amp;quot; to perform logical right shifts, but because the logical and arithmetic left-shift operations are identical, there is no &amp;quot;&amp;lt;code&amp;gt;&amp;amp;lt;&amp;amp;lt;&amp;amp;lt;&amp;lt;/code&amp;gt;&amp;quot; operator in Java.&lt;br /&gt;
&lt;br /&gt;
More details of Java shift operators:&amp;lt;ref&amp;gt;The Java Language Specification, section [http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.19 15.19. Shift Operators]&amp;lt;/ref&amp;gt;&lt;br /&gt;
* The operators &amp;lt;code&amp;gt;&amp;lt;&amp;lt;&amp;lt;/code&amp;gt; (left shift), &amp;lt;code&amp;gt;&amp;gt;&amp;gt;&amp;lt;/code&amp;gt; (signed right shift), and &amp;lt;code&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;lt;/code&amp;gt; (unsigned right shift) are called the &#039;&#039;shift operators&#039;&#039;.&lt;br /&gt;
* The type of the shift expression is the promoted type of the left-hand operand. For example, &amp;lt;code&amp;gt;aByte &amp;gt;&amp;gt;&amp;gt; 2&amp;lt;/code&amp;gt; is equivalent to &amp;lt;code&amp;gt;((int) aByte) &amp;gt;&amp;gt;&amp;gt; 2&amp;lt;/code&amp;gt;.&lt;br /&gt;
* If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator &amp;amp; with the mask value 0x1f (0b11111).&amp;lt;ref name=&amp;quot;jls15.22.1&amp;quot;&amp;gt;[http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.22.1 JLS §15.22.1]&amp;lt;/ref&amp;gt; The shift distance actually used is therefore always in the range 0 to 31, inclusive.&lt;br /&gt;
* If the promoted type of the left-hand operand is long, then only the six lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator &amp;amp; with the mask value 0x3f (0b111111).&amp;lt;ref name=&amp;quot;jls15.22.1&amp;quot;/&amp;gt; The shift distance actually used is therefore always in the range 0 to 63, inclusive.&lt;br /&gt;
* The value of &#039;&#039;n &amp;gt;&amp;gt;&amp;gt; s&#039;&#039; is &#039;&#039;n&#039;&#039; right-shifted &#039;&#039;s&#039;&#039; bit positions with zero-extension.&lt;br /&gt;
&lt;br /&gt;
===Shifts in Pascal===&lt;br /&gt;
In Pascal, as well as in all its dialects (such as [[Object Pascal]] and [[GNU Pascal|Standard Pascal]]), the left and right shift operators are &amp;quot;&amp;lt;code&amp;gt;shl&amp;lt;/code&amp;gt;&amp;quot; and &amp;quot;&amp;lt;code&amp;gt;shr&amp;lt;/code&amp;gt;&amp;quot;, respectively. The number of places to shift is given as the second argument. For example, the following assigns &#039;&#039;x&#039;&#039; the result of shifting &#039;&#039;y&#039;&#039; to the left by two bits:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;source lang=&amp;quot;pascal&amp;quot;&amp;gt;x := y shl 2;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Applications==&lt;br /&gt;
Bitwise operations are necessary particularly in lower-level programming such as writing device drivers, low-level graphics, communications protocol packet assembly, and decoding.&lt;br /&gt;
&lt;br /&gt;
Although machines often have efficient built-in instructions for performing arithmetic and logical operations, in fact, all these operations can be performed by combining the bitwise operators and zero-testing in various ways.{{Citation needed|date=May 2012}}&lt;br /&gt;
&lt;br /&gt;
For example, here is a [[pseudocode]] example showing how to multiply two arbitrary integers &amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;a&amp;lt;/code&amp;gt; greater than &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;) using only bitshifts and addition:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 c = 0&lt;br /&gt;
 &#039;&#039;&#039;while&#039;&#039;&#039; b ≠ 0&lt;br /&gt;
     &#039;&#039;&#039;if&#039;&#039;&#039; (b &#039;&#039;&#039;and&#039;&#039;&#039; 1) ≠ 0&lt;br /&gt;
         c = c + a&lt;br /&gt;
     left shift a by 1&lt;br /&gt;
     right shift b by 1&lt;br /&gt;
  &lt;br /&gt;
 &#039;&#039;&#039;return&#039;&#039;&#039; c&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NB: In this code &amp;lt;code&amp;gt;=&amp;lt;/code&amp;gt; is the assignment operator, not the equality operator.&amp;lt;BR/&amp;gt;&lt;br /&gt;
This implementation of [[ancient Egyptian multiplication]], like most [[multiplication algorithm]]s, involves bitshifts. In turn, even addition can be written using just bitshifts and zero-testing{{Citation needed|date=May 2012}}:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 &#039;&#039;&#039;while&#039;&#039;&#039; a ≠ 0&lt;br /&gt;
     c = b &#039;&#039;&#039;and&#039;&#039;&#039; a&lt;br /&gt;
     b = b &#039;&#039;&#039;xor&#039;&#039;&#039; a&lt;br /&gt;
     left shift c by 1&lt;br /&gt;
     a = c&lt;br /&gt;
 &lt;br /&gt;
 &#039;&#039;&#039;return&#039;&#039;&#039; b&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NB: In this code &amp;lt;code&amp;gt;=&amp;lt;/code&amp;gt; is the assignment operator, not the equality operator.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Bit manipulation]]&lt;br /&gt;
*[[Bitboard]]&lt;br /&gt;
*[[Bitwise operations in C]]&lt;br /&gt;
*[[Boolean algebra (logic)]]&lt;br /&gt;
*[[Double dabble]]&lt;br /&gt;
*[[Find first set]]&lt;br /&gt;
*[[Karnaugh map]]&lt;br /&gt;
*[[Logic gate]]&lt;br /&gt;
*[[Logical operator]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://www.miniwebtool.com/bitwise-calculator/ Online Bitwise Calculator] supports Bitwise AND, OR and XOR&lt;br /&gt;
*[http://www.cs.uiowa.edu/~jones/bcd/divide.html Division using bitshifts]&lt;br /&gt;
* &amp;quot;[http://demonstrations.wolfram.com/BitwiseOperationsModN/ Bitwise Operations Mod N]&amp;quot; by Enrique Zeleny, [[Wolfram Demonstrations Project]].&lt;br /&gt;
* &amp;quot;[http://demonstrations.wolfram.com/PlotsOfCompositionsOfBitwiseOperations/ Plots Of Compositions Of Bitwise Operations]&amp;quot; by Enrique Zeleny, The Wolfram Demonstrations Project.&lt;br /&gt;
&lt;br /&gt;
{{DEFAULTSORT:Bitwise Operation}}&lt;br /&gt;
[[Category:Binary arithmetic]]&lt;br /&gt;
[[Category:Operators (programming)]]&lt;br /&gt;
[[Category:Articles with example pseudocode]]&lt;br /&gt;
[[Category:Boolean algebra]]&lt;/div&gt;</summary>
		<author><name>98.248.229.177</name></author>
	</entry>
</feed>