Binary Rotate Left Calculator – Free

This rotate left calculator performs a circular left shift on a binary word. Bits pushed out of the most significant end wrap around to the least significant end, so nothing is lost.

How to use the Rotate left Calculator tool

  1. Enter the word in the Binary digits field, including any leading zeros, because the digit count sets the word width.
  2. Enter the rotation amount in the Number of positions field.
  3. Select Rotate left. The Example button rotates 10110001 by 2.
  4. Read the rotated word, which has the same number of digits, in the Result box.
  5. Select Copy to copy it, or Clear to start again.

How rotate left works

A rotation treats the word as a ring. Rotating left by n takes the n leftmost bits off the front and attaches them to the back, while every other bit moves n places toward the high end. The count of 1s and 0s never changes, only their positions.

The calculator does this on the digit string itself. The width is the number of binary digits you enter, and the rotation amount is reduced modulo that width. Rotating an 8-bit word by 8 returns it unchanged, and rotating by 10 is the same as rotating by 2.

Worked example: 10110001 rotated left by 2

Split 10110001 after its first two digits into 10 and 110001. Move the front piece to the end and you get 11000110. Leading zeros are part of the word: 00010110 rotated left by 3 is 10110000, still eight digits.

10110001 rol 2   =  11000110
10110001 rol 10  =  11000110   (10 mod 8 = 2)
00010110 rol 3   =  10110000
1000 rol 1       =  0001

Rotate left in languages and CPUs

x86 has a ROL instruction, and ARM gets the same effect with a right rotation by the width minus n. C and older C++ have no rotate operator, so code spells it as a left shift OR-ed with a right shift by the complementary amount, a pattern compilers recognize and turn into one instruction. Newer standard libraries name it directly: std::rotl in C++20, rotate_left in Rust and Integer.rotateLeft in Java.

Left rotations are a staple of hashing and cryptography because they mix high bits back into low positions without discarding data. MD5 and SHA-1 rotate left in every step, the ChaCha20 quarter round rotates left by 16, 12, 8 and 7 bits, and MurmurHash3 uses left rotations in its mixing loop.

Input rules and width handling

Check these points if the tool reports an error or the result has a width you did not expect.

  • Binary digits: 1 to 65,536 characters of 0 and 1. A 0b prefix and spaces are dropped and do not count toward the width.
  • Number of positions: a whole number from 0 to 4096. Amounts larger than the width wrap around.
  • The output always has exactly as many digits as the input.
  • Rotation through a carry flag, as done by the x86 RCL instruction, is not modeled.

Frequently asked questions

What is the difference between rotate left and shift left?

A left shift fills the right side with zeros and, in a fixed-width word, discards the bits that leave on the left. A left rotation reinserts those bits on the right. Rotations are reversible and shifts are not.

How does the calculator know the word size?

It uses the number of binary digits you type. To rotate a value as a 16-bit or 32-bit word, pad it on the left with zeros to that length before selecting Rotate left.

What happens when the rotation count is larger than the width?

The count is taken modulo the width. For an 8-bit word, 9 positions behaves like 1 and 16 positions behaves like 0. The form accepts counts up to 4096.

How do I reverse a left rotation?

Rotate right by the same amount, or rotate left by the width minus that amount. Rotating 11000110 right by 2 with the Rotate right Calculator returns the original 10110001.

Does rotating change the number of set bits?

No. A rotation only rearranges bits. The population count and the parity of the word stay the same, which is one way to sanity-check a rotation routine.

Related tools