User Rating 0.0
Total Usage 0 times
0 characters
Presets:
Is this tool helpful?

Your feedback helps us improve.

About

Circular right rotation shifts every character in a string by k positions toward the end. Characters that overflow past the last index wrap back to the beginning. This is the string equivalent of a bitwise rotate-right (ROR) instruction used in CPU architectures and cryptographic primitives like SHA-256. Getting the rotation count wrong by even one position produces entirely different ciphertext or garbled protocol headers. This tool computes s = s[n k mod n :] + s[: n k mod n] where n is the string length. It handles edge cases: zero-length input, rotation counts exceeding string length via modulo arithmetic, and negative values converted to their positive right-rotation equivalent.

Circular rotation is distinct from a linear shift. A linear shift discards overflow characters and pads with nulls. A circular rotation preserves all characters. The operation is periodic with period n: rotating by n returns the original string. This tool visualizes each intermediate step so you can trace the permutation sequence. Useful for debugging data-link framing, testing string algorithms, or preparing competitive programming inputs.

text rotation circular shift string rotation text manipulation rotate characters right caesar shift text formatter

Formulas

The circular right rotation of a string s of length n by k positions is defined as the concatenation:

s = s[n k :] + s[: n k]

where the effective rotation count is computed via modular arithmetic:

k = ((k mod n) + n) mod n

This double-modulo formulation handles negative values of k correctly. A negative k converts to its equivalent right-rotation offset. The operation forms a cyclic group of order n under composition: applying the rotation n times returns the original string. Formally, Rn(s) = s s S.

Where s = input string, n = length of s (Unicode-aware, using Array.from), k = requested rotation positions (integer, may be negative), k = effective rotation after modulo normalization, s = resulting rotated string.

Reference Data

OriginalRotation (k)ResultNote
ABCDEF1FABCDELast char wraps to front
ABCDEF2EFABCDLast 2 chars wrap
ABCDEF6ABCDEFk = n, full cycle
ABCDEF7FABCDEk mod n = 1
ABCDEF0ABCDEFIdentity operation
Hello World3rldHello WoSpaces rotate too
12345245123Digits treated as chars
A99ASingle char is invariant
(empty)5 (empty)Empty string returns empty
🔥🌊⚡1⚡🔥🌊Works with Unicode/emoji
ABCDEF−2CDEFABNegative left rotation
10110011301110110Binary string ROR
AABBAABB4AABBAABBPeriod divides n
Caesar3sarCaePositional rotation, not alphabetical
OpenAI12OpenAI12 mod 6 = 0

Frequently Asked Questions

A linear right shift moves characters to the right and discards those that fall off the end, padding the left with empty or null values. Circular rotation wraps the overflowing characters back to the beginning. No data is lost. If your string is ABCDEF and k = 2, a linear shift yields __ABCD (EF lost), while circular rotation yields EFABCD (all characters preserved).
The tool applies modulo arithmetic: k = k mod n. Rotating a 6-character string by 8 positions is equivalent to rotating by 2 positions. Rotating by exactly n returns the original string since the rotation group has order n.
Yes. The tool uses Array.from(s) to split the string into Unicode code points rather than UTF-16 code units. This means a flag emoji (which is 4 bytes) counts as 1 character, not 2. Without this, a rotation could split a surrogate pair and produce corrupted output.
A negative k is interpreted as a left rotation. Internally, it is converted to an equivalent right rotation via k = ((k mod n) + n) mod n. For a 6-character string, rotating by −2 is the same as rotating right by 4.
Bitwise ROR operates on fixed-width binary words (8, 16, 32, or 64 bits). This tool applies the same cyclic permutation logic but to an arbitrary-length sequence of characters instead of bits. The mathematical group structure is identical: both are elements of the cyclic group Z/nZ.
Yes. Circular rotation is invertible. To undo a right rotation by k, apply a right rotation by n k (or equivalently, a left rotation by k, i.e., input k). The tool accepts negative values for this purpose.