Bit Rotate Calculator
This bit rotate calculator performs a circular left or right rotation inside a fixed-width unsigned integer.
Run — free
Bits that leave one end of the selected register immediately reappear at the other end, matching the behavior used in shift-register logic, cryptographic primitives, checksums, embedded code, and low-level data formats. Enter a decimal, hexadecimal, or binary value, choose its width and direction, and set any non-negative rotation count. The calculator preserves leading zero positions and reports exact decimal, fixed-width binary, and padded hexadecimal results.
Choose the value and its exact register width
A rotation only has meaning when the bit width is known. The same numeric value can produce different results in an 8-bit register and a 16-bit register because each width places the wraparound boundary somewhere different. Enter the unsigned value in ordinary decimal notation, or use a 0x prefix for hexadecimal and a 0b prefix for binary. Then select a width from 1 through 4096 bits. The value must fit completely inside that width; rejecting oversized values prevents an implicit truncation from hiding information. Leading zero positions are part of the register even though they are not written in the input. For example, decimal 5 at a width of 8 is treated as binary 00000101, not merely 101. The returned binary field is always padded to the exact selected width, while the hexadecimal field is padded to enough complete hexadecimal digits to represent that width. This explicit representation makes it easier to compare a result with a register diagram, protocol field, debugger display, or programming-language implementation.
Understand circular left and right movement
A circular rotation differs from an ordinary logical shift because no bit is discarded and no new zero is inserted. During a left rotation, bits move toward the most significant end; any bits that cross that boundary wrap into the least significant positions. During a right rotation, movement is reversed, and bits leaving the least significant end return at the most significant end. The calculator applies the operation to the full fixed-width pattern in one exact integer computation. A rotation count equal to the width returns the original pattern, as does any count that is a whole multiple of the width. For that reason, the submitted count is reduced modulo the width, and the effective count is included as normalized_shift in the result. This is useful when checking code that accepts unrestricted counts or when modeling hardware in which the rotation selector only needs enough states for one register width. A zero effective count is handled directly and preserves the value without performing an invalid full-width shift.
Read the output and verify an implementation
The response retains the original value in normalized decimal form, the chosen width, requested rotation count, effective rotation count, and direction. It then presents the rotated value in decimal, fixed-width binary, and uppercase hexadecimal. These equivalent forms serve different verification tasks: binary exposes every wrapped bit, hexadecimal matches registers and machine-oriented documentation compactly, and decimal is convenient for APIs or test fixtures that avoid prefixed literals. To test an implementation, use a pattern with set bits near both ends of the register so incorrect shifting becomes obvious. Also test a zero count, a count exactly equal to the width, and a count larger than the width. Those cases catch common mistakes involving modulo reduction and language-specific shift-count behavior. The algorithm uses arbitrary-precision integer arithmetic rather than JavaScript's 32-bit bitwise operators, so widths above 32 bits do not suffer signed conversion or silent count masking. Processing is deterministic, local, and bounded; it makes no network request and uses no random or time-dependent state.
What you can do with it
Check embedded register logic
Compare firmware rotation output with an exact fixed-width binary pattern before writing or reviewing device code.
Verify cryptographic steps
Confirm circular rotations used in hash functions, ciphers, and mixing operations without 32-bit signed arithmetic surprises.
Build protocol test vectors
Generate decimal, binary, and hexadecimal expected values for fields whose bits wrap inside a specified width.
FAQ
What is the difference between rotating and shifting bits?
A logical shift discards bits at one end and inserts zeros at the other. A rotation wraps discarded bits around to the opposite end, so every bit remains in the fixed-width pattern.
What happens when the rotation count exceeds the width?
The count is reduced modulo the width. The response shows both the requested shift and the normalized effective shift.
Can I enter hexadecimal or binary values?
Yes. Prefix hexadecimal input with 0x and binary input with 0b. Unprefixed input is interpreted as decimal.
Why must the value fit within the selected width?
Automatic truncation could silently remove high bits and produce a misleading result. The calculator rejects the value so you can correct either the value or the width explicitly.
How much does an API request cost?
Each API request costs $0.002. The browser version runs the same deterministic calculation locally.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/elec/rotate-bits \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"value":"150","width":8,"shift":3,"direction":"left"}'const res = await fetch("https://api.kit.forhosting.com/elec/rotate-bits", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"value": "150",
"width": 8,
"shift": 3,
"direction": "left"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/elec/rotate-bits",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"value": "150",
"width": 8,
"shift": 3,
"direction": "left"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/elec/rotate-bits", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"value":"150","width":8,"shift":3,"direction":"left"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"value":"150","width":8,"shift":3,"direction":"left"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/elec/rotate-bits", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"value": "150",
"width": 8,
"shift": 3,
"direction": "left"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "elec.rotate_bits",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |