Home

Bit Rotation Calculator

Rotate bits left (ROL) or right (ROR) in an 8-, 16-, 32- or 64-bit word. See wrapped bits, exact values and signed or unsigned results.

Enter your numbers

Live calculation
Try an example:

ROL moves bits toward the most significant end; ROR moves them toward the least significant end. Bits wrap around.

Explicit word size. Every bitwise result is limited to this width.

Use the input base and signedness shown below. Values must fit the selected word size; matching prefixes are allowed.

Nonnegative whole number, up to 1 trillion. The effective count is count modulo word size: 9 on 8 bits equals 1.

Also included in this result: Input base: 10 · Interpretation: Unsigned.

Additional settings (2)

Whole-number radix from 2 to 36. Common bases: binary 2, octal 8, decimal 10, hexadecimal 16.

Two’s complement changes decimal interpretation. Rotation always moves the same finite bit pattern and uses no carry flag.

Results update as you type. Example values are editable.

Result

3

8-bit unsigned decimal after ROL.

Bits leaving one end re-enter at the other. The dashed cells identify wrapped bits; this operation does not use a carry flag.

Before rotation

After rotation

Most significant bit first. Each cell shows its position and value. Dashed cells mark bits that wrapped to the opposite end.

Inputs stay on this page. Reloading clears unsaved changes.

More results, charts and tables
Binary00000011
Hexadecimal0x03
Signed decimal3
Effective rotation1 bit1 modulo 8 = 1.
Set bits preserved2Rotation preserves the number of 1 bits.
How it is calculated
For a word of width w, normalize the nonnegative count: n = count mod w. If n = 0, return the unchanged bit pattern. ROL = ((x << n) OR (x >> (w − n))) AND mask. ROR = ((x >> n) OR (x << (w − n))) AND mask, where mask = 2^w − 1 and x is the unsigned bit pattern. Signedness changes how decimal input and output are interpreted; the circular bit movement is the same. This is a rotation without carry, not an arithmetic shift, text rotation, or geometric rotation. Supported widths: 8, 16, 32 and 64. Counts are whole numbers from 0 to 1 trillion; negative counts are rejected. Prefixes must match the selected input base. In signed decimal mode, input must fit the signed range; other bases may specify a positive raw bit pattern.

Bit Rotation Calculator

CalcsDecoded.com

Result

3

8-bit unsigned decimal after ROL.

Bits leaving one end re-enter at the other. The dashed cells identify wrapped bits; this operation does not use a carry flag.
Result breakdown
MeasureResult
Binary00000011
Hexadecimal0x03
Signed decimal3
Effective rotation1 bit1 modulo 8 = 1.
Set bits preserved2Rotation preserves the number of 1 bits.

Inputs used

  • Rotation direction: Rotate left (ROL)
  • Word size: 8 bits
  • Integer to rotate: 129
  • Rotation count: 1
  • Input base: 10
  • Interpretation: Unsigned

Method and assumptions

For a word of width w, normalize the nonnegative count: n = count mod w. If n = 0, return the unchanged bit pattern. ROL = ((x << n) OR (x >> (w − n))) AND mask. ROR = ((x >> n) OR (x << (w − n))) AND mask, where mask = 2^w − 1 and x is the unsigned bit pattern. Signedness changes how decimal input and output are interpreted; the circular bit movement is the same. This is a rotation without carry, not an arithmetic shift, text rotation, or geometric rotation. Supported widths: 8, 16, 32 and 64. Counts are whole numbers from 0 to 1 trillion; negative counts are rejected. Prefixes must match the selected input base. In signed decimal mode, input must fit the signed range; other bases may specify a positive raw bit pattern.

Examples and assumptions

Rotate a finite bit pattern left or right. Bits wrap around the word; signedness changes decimal interpretation, not the circular bit movement.

8-bit rotate left

3 = 00000011 = 0x03.

129 is 10000001. Rotate left by one: the leading 1 wraps into bit 0, producing 00000011.

8-bit rotate right

192 = 11000000 = 0xC0.

The trailing 1 wraps into bit 7. The remaining bits move right by one.

Count larger than the word

3; effective rotation 1 bit.

9 modulo 8 is 1. One full turn restores the original word; the remaining step produces 00000011.

Before you use the result

  • Supported word sizes are 8, 16, 32 and 64. Inputs must fit the selected signed or unsigned interpretation. Matching binary, octal and hexadecimal prefixes follow the input base.
  • Counts are nonnegative whole numbers from 0 to 1 trillion and are normalized modulo word size. Zero and full turns return the unchanged pattern. Negative counts are rejected; select the opposite direction instead.
  • This tool rotates without carry. It does not simulate processor flags, rotate-through-carry instructions, text rotation or geometric rotation. Exact instruction count rules may differ by language or processor.
Calculation checks and references

Independent string-rotation references verify every 8-bit pattern at counts 0–16, plus cases for all supported widths, both directions and signedness modes, inverse rotations, large counts, count normalization and preservation of set bits. Existing programmer arithmetic and bitwise references are rerun.

Reference cases checked: . Checks are automated reference calculations; an independent professional review is not claimed.

References explain definitions, rules or context; they do not endorse CalcsDecoded.com. See our calculation methodology for the testing and updating standard.

Frequently asked questions

How is rotation different from shifting?

Rotation returns bits leaving one end to the other end. A logical shift inserts zeros and may discard bits. Rotation preserves the number of set bits.

What if the rotation count is larger than the word size?

The count is reduced modulo the selected width. For 8 bits, 9 steps is equivalent to 1; 8 steps leaves the pattern unchanged.

Does signed mode change how bits rotate?

No. It changes the accepted decimal input range and decimal result interpretation. The same two’s-complement pattern moves in the same circle.

Does this rotate through the carry flag?

No. ROL/ROR here rotate only the selected word. No carry flag or CPU instruction state is modeled.