Binary Bit Field Tool

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.

✓ Extract Multiple Bits ✓ Inclusive Range ✓ Position 0 = Rightmost ✓ Preserve Leading Zeros ✓ Instant Result
RNG
Bit Range Extraction
● Ready
Positions are inclusive. Position 0 is the rightmost bit. Example: low 2 and high 5 extracts positions 5, 4, 3 and 2.
Try:
✓ Extracted Bit Range
Extracted bits from high position down to low position
Range 0:0
Extracted Width 1
Decimal Value 0
Range Extraction Breakdown

What Is a Binary Bit Range?

A binary bit range is a continuous group of adjacent bit positions selected from a larger binary word.

Input: 11010110 Positions: 7 6 5 4 3 2 1 0 1 1 0 1 0 1 1 0 Extract positions 5 through 2: Positions 5,4,3,2 → 0 1 0 1 Result: 0101

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: 11010110 Position map: Position: 7 6 5 4 3 2 1 0 Bits: 1 1 0 1 0 1 1 0 Requested range: [5:2] Selected bits: 0 1 0 1 Extracted binary: 0101 Decimal value: 5

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.

Range: 5 through 2 contains: 5, 4, 3, 2 Therefore its width is: 5 – 2 + 1 = 4 bits

Bit Range Width Formula

For an inclusive range from high position H to low position L:

Width = H – L + 1 For positions 7 through 4: 7 – 4 + 1 = 4 bits

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.

Conceptually: Width = High – Low + 1 Mask = (1 << Width) - 1 Result = (Value >> Low) AND Mask

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.

From: 11010110 Extract: [5:2] Result: 0101 It must not be reduced to 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.

For: 101101 Range: [2:2] Result: 1

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.

Valid: High = 5 Low = 2 Invalid: High = 2 Low = 5

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.

Important: BinaryCon uses position 0 as the rightmost bit. The low and high positions are both included, and leading zeros in the extracted bit field are preserved.

Related BinaryCon Tools

Binary Bit Range Calculator FAQs

What does a binary bit range calculator do?
It extracts multiple adjacent bits between a selected high and low position.
Which bit is position 0?
Position 0 is the rightmost, least significant bit.
Are both ends of the range included?
Yes. Both the high and low positions are included.
What is range 5:2 of 11010110?
Positions 5 through 2 are 0101.
How many bits are in range 5:2?
There are four bits because 5 - 2 + 1 = 4.
Can low and high positions be the same?
Yes. In that case the calculator extracts exactly one bit.
Can the low position be greater than the high position?
No. The high position must be greater than or equal to the low position.
Are leading zeros preserved in the extracted range?
Yes. The exact width of the selected bit field is preserved.
How is a bit range extracted in programming?
A common technique is to right-shift by the low position and then apply a mask whose width equals high minus low plus one.
What if a selected position is outside the input width?
The calculator displays an error because the requested range does not exist.
Scroll to Top