Hex Bit Set Calculator
Set a specific bit of a hex value to 1 by its index — every other bit stays exactly as it was, with the before/after binary shown side by side.

Built by
Swapnil SanghviFull-Stack Web Developer & WordPress Developer
Swapnil Sanghvi is a full-stack web and WordPress developer, UI designer, and full-time freelancer who builds and maintains Hex Calculator.
Further reading: Bitwise operation — Wikipedia
How to Set a Specific Bit
Build a mask with only the target bit index set to 1 (all other bits 0), then OR that mask with your value. OR guarantees the target bit becomes 1 while every other bit passes through untouched.
Bit Set Example, Step by Step
Set bit 3 of 0x00 = 0x08
0x00 with bit 3 set = 0x08
0000 0000 (0x00) 0000 1000 (mask: bit 3) ----------- 0000 1000 (0x08, OR)
| Step | Description | Result |
|---|---|---|
| Build the bit-3 mask | 1 shifted left by 3 = 0b1000 | 0x08 |
| OR with the value | 0x00 | 0x08 | 0x08 |
Every bit besides bit 3 was already 0 here, so the result equals the mask exactly — setting a bit in a nonzero value would instead only change that one bit position, leaving the rest intact.
Where Bit Set Actually Comes Up
Enabling a Single Hardware Register Bit
Turning on one control bit in a microcontroller register — like enabling an interrupt or a peripheral — without disturbing any of the register's other configured bits.
register |= (1 << ENABLE_BIT)
Turning On One Option Flag
Setting a specific bit in a flags value to enable one feature while leaving every other previously-set flag exactly as it was.
flags | (1 << READ_ONLY_BIT)
Building Up a Bitmask One Bit at a Time
Constructing a bitmask incrementally by setting individual bits, useful when the set of active bits is determined by a loop or conditional logic rather than known up front.
mask = setBit(mask, i) for each active i
Why Use This Calculator Instead of Doing It by Hand
- Builds the bit mask and applies the OR for you, no manual shifting required
- Supports 8/16/32/64-bit widths
- Runs entirely in your browser — nothing you type gets sent anywhere
- Also available in Clear and Toggle modes in the same calculator
Limitations
- Sets one bit at a time — to set several specific bits at once, build a combined mask with the Hex Bit Mask Calculator and OR it in yourself.
- Bit index must be within the selected bit width (0 to width-1).
Frequently Asked Questions
How do you set one specific bit in a hex value?
OR the value with a mask that has only that one bit set (1 shifted left by the bit's index) — every other bit passes through unchanged, and the target bit becomes 1 regardless of what it was before.
What does "bit index 0" mean?
It's the least significant bit — the rightmost bit, worth 1 (2^0). Bit index 1 is worth 2, bit index 7 is worth 128, and so on, counting from the right.
What if the bit is already 1?
Nothing changes — setting a bit that's already 1 leaves it at 1, since OR with 1 always gives 1 regardless of the starting value.
How is Bit Set different from Bit Toggle?
Set always forces the target bit to 1, no matter its starting value. Toggle flips it — 0 becomes 1, but 1 becomes 0. Use Set when you want a guaranteed 1 regardless of the current state.