Binary Bit Range Calculator
Extract a continuous range of bits from any binary string. Enter the lowest and highest bit positions using zero-based indexing from the right and instantly isolate the selected binary field.
What Is a Binary Bit Range?
A binary bit range is a continuous group of adjacent bit positions selected from a larger binary word.
How to Extract a Bit Range
1. Enter the Binary String
Use only 0 and 1.
2. Choose the Low Position
This is the least significant position included in the range.
3. Choose the High Position
This is the most significant position included in the range.
4. Extract Every Included Bit
The calculator returns all bits from high down through low.
Example: Extract Bits 5 Through 2
Binary Bit Range Examples
| Binary | Range | Extracted Bits | Width |
|---|---|---|---|
11010110 |
7:4 | 1101 |
4 |
11010110 |
5:2 | 0101 |
4 |
11010110 |
3:0 | 0110 |
4 |
101101 |
2:0 | 101 |
3 |
101101 |
4:2 | 011 |
3 |
00101101 |
7:4 | 0010 |
4 |
Inclusive Bit Ranges
Both position values are included in the extracted result.
Bit Range Width Formula
For an inclusive range from high position H to low position
L:
Bit Range Extraction with Shift and Mask
In programming, a range is often extracted by first shifting the low position to bit 0 and then applying a mask matching the desired width.
This calculator performs the equivalent operation directly on the supplied binary string so that leading zeros in the extracted field remain visible.
Why Leading Zeros in the Result Matter
An extracted field may begin with one or more zero bits. Those zeros must remain because they are part of the selected range width.
101, because the selected field is
four bits wide.
Bit Range vs Single-Bit Extraction
| Operation | Output |
|---|---|
| Single Bit Extraction | Returns one selected 0 or 1 bit. |
| Bit Range Extraction | Returns multiple continuous adjacent bits. |
What If Low and High Are the Same?
A range containing the same low and high position is valid and simply extracts one bit.
What If Low Is Greater Than High?
This calculator expects the conventional order where the high position is greater than or equal to the low position.
Where Are Bit Ranges Used?
Hardware Registers
Registers often contain multi-bit fields such as mode, status, or configuration values.
Network Protocols
Packed packet headers may store multiple fields inside one binary word.
Instruction Encoding
Machine instructions divide binary words into opcode and operand fields.
Bitmask Programming
Shift-and-mask operations are commonly used to isolate adjacent bits.
Common Bit Range Mistakes
Counting Positions from the Left
BinaryCon uses position 0 on the right.
Forgetting Inclusive Endpoints
Both low and high positions are included.
Dropping Leading Zeros
Leading zeros inside the selected range are part of the extracted field.
Using Positions Outside the Width
Both positions must exist inside the entered binary string.
Related BinaryCon Tools
Binary Bit Range Calculator FAQs
What does a binary bit range calculator do?
Which bit is position 0?
Are both ends of the range included?
What is range 5:2 of 11010110?
0101.
How many bits are in range 5:2?
5 - 2 + 1 = 4.