Binary to Hex Converter
Result
Hexadecimal
- Grouped in fours
- 1011 0010
A binary to hex converter rewrites a number from base two into base sixteen. It is the easiest conversion in this family, because nothing is actually calculated: one hexadecimal digit holds exactly four binary digits, so the whole job is to cut the binary string into groups of four from the right and read each group as a single digit. 10110010 splits into 1011 and 0010, which are B and 2, so the answer is B2. That fixed four-to-one relationship is the reason hexadecimal exists at all — a byte is eight bits, therefore exactly two hexadecimal digits, and a sixteen-bit address is exactly four of them — and it is why programmers write machine code, colour values and memory addresses in this base rather than in binary. The page prints the grouping it used underneath the answer, because the grouping is the conversion. If the number of digits is not a multiple of four, the leftmost group is padded with zeros so that it is: 10110 becomes 0001 0110, which is 16. Those zeros do not change the value, only the grouping.
All sixteen four-bit groups and the hexadecimal digit each one stands for
| Nibble | Hex digit | Decimal |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0010 | 2 | 2 |
| 0011 | 3 | 3 |
| 0100 | 4 | 4 |
| 0101 | 5 | 5 |
| 0110 | 6 | 6 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1001 | 9 | 9 |
| 1010 | A | 10 |
| 1011 | B | 11 |
| 1100 | C | 12 |
| 1101 | D | 13 |
| 1110 | E | 14 |
| 1111 | F | 15 |
This is the entire conversion, written out. Every four-bit group there is appears exactly once, so nothing has to be worked out at the moment of use — the table is closed, and a reader who has scanned it once can read any binary string in this base by cutting it into fours and looking each piece up. It is fixed rather than derived from the input above it, so it does not change when the number does, and it is not a contradiction when the two seem to disagree: the panel answers what was typed, the table answers the general question of what the sixteen groups are. Read the middle column downward and it counts from 0 to F with no gaps, which is the point — the letters are not a code but the continuation of the digits past nine. Read the first column downward and it counts upward in binary by exactly the same amount, which is what makes the correspondence mechanical. The table stops at 1111 because that is where one hexadecimal digit ends: the next value needs a second digit, and that is the regrouping the page above it already does.
Formula
10110010 = 1011 0010 = B2
- binary
- The number to rewrite, written in base two. Nothing about it is changed by the conversion — the same value is simply written with a different set of digits
- nibble
- One group of four binary digits. It is the unit this conversion works in, and there are exactly sixteen possible nibbles, which is exactly why base sixteen is the base that pairs with binary
- 0-9, A-F
- The sixteen hexadecimal digits, one per nibble. Ten of them are the familiar numerals and the remaining six are the letters A to F, standing for ten through fifteen
- padding
- Zeros added on the left of the first group when the digit count is not a multiple of four. They change the grouping and never the value, which is why 10110 and 00010110 are two ways of writing the same number
- from the right
- The direction the cutting runs. Groups are formed from the right-hand end because that is where the ones position is, exactly as thousands are separated in a decimal number
- 53 bits
- How long the input may be: fifty-three binary digits, which is 9007199254740991 and comes to fourteen hexadecimal digits at the other end. It is the width at which a machine stops being able to tell neighbouring whole numbers apart, so a longer input is refused rather than rounded
This conversion is the one people perform most often without thinking of it as a conversion. Reading a byte in a debugger, checking a colour value, working out a subnet mask, decoding a hash prefix, reading a device register dump, or comparing two flags in a log are all cases where the bits are the truth and the hexadecimal is the form they are printed in — and going back and forth between those two views is a constant in low-level work. The direction matters in both senses: a hardware datasheet gives a register as a hexadecimal value and the bit that has to be checked is found by expanding it, while an oscilloscope trace or a bit-pattern question arrives in binary and has to be written down in the form the documentation uses. Students meet it as the shortcut that makes long binary numbers manageable: a sixteen-digit binary string is unreadable and its four hexadecimal digits are not, and knowing that the relationship is four-to-one rather than something to work out removes the arithmetic from the task entirely. The page prints the grouping so the shortcut is visible rather than asserted, which is what makes it usable as a check on a hand conversion as well as a replacement for one.
Worked examples
Rewriting 10110010
- Cut the string into groups of four, starting from the right: 1011 and 0010
- Read the first group: 1011 is 8 + 2 + 1 = 11, which is B
- Read the second group: 0010 is 2, which is 2
- The two digits together give B2
The default, and a byte, so the grouping comes out even. B2 is the form this value would appear in inside a debugger or a data sheet — the eight bits are still there underneath, which is why the grouping is printed beside the answer instead of being left implicit.
A single nibble, 1111
- Four digits is already exactly one group
- 1111 is 8 + 4 + 2 + 1 = 15
- Fifteen is written F in hexadecimal
- The answer is a single digit, F
The largest nibble, and the one that shows why the letters run out where they do: fifteen is the highest value four bits can hold, so F is the last digit in the base. Nothing wider can be written with one hexadecimal digit, and that is exactly the property being exploited.
Padding a short input, 10110
- Five digits do not divide into fours, so start from the right: 0110 is one full group
- One digit is left over on the left, so pad it out to four: 0001
- 0001 is 1, and 0110 is 6, giving the two digits 16
- The grouping shown is 0001 0110, which is two digits longer than the input
The case that looks like a mistake and is not. The output grouping is longer than the input because a hexadecimal digit is four bits wide and the last group has to be filled to that width. 10110 and 00010110 are the same number, and the padding is what makes the second digit readable — without it the leftover single digit would have no digit to be.
A negative value, -10110
- The minus sign sits outside the number, so set it aside and convert 10110
- 10110 regroups as 0001 0110, which reads 16
- Put the sign back on both readings: -16
The sign stays outside the digits on both outputs. Folding it in would require a fixed width to fold it into, and there is none here — a processor storing this value in eight bits would write a pattern of ones and zeros that depends entirely on the width being eight. The hexadecimal reading keeps the sign for the same reason the binary one does.
Limitations
This page rewrites whole binary numbers only. There is no binary point, so a fractional input is refused rather than converted, and no hexadecimal fraction is produced. The input may be at most fifty-three binary digits long, which is 9007199254740991 and fourteen hexadecimal digits at the other end; longer values cannot be held exactly by a machine and are refused rather than approximated. Leading zeros in the input are accepted and ignored, but zeros added by the grouping are shown deliberately — a padded output is wider than its input on purpose, and that is not an error. A minus sign in front is accepted and carried to both outputs. Whole numbers only, so this is a reading conversion and not arithmetic: adding, subtracting, multiplying and dividing in either base is on the calculator pages linked below, and going the other way, from hexadecimal back to binary, is on its own page.
Frequently asked questions
- Why is the output longer than what I typed?
- Because a hexadecimal digit is exactly four bits wide and the leftmost group has to be filled to that width. A five-digit input such as 10110 is one full group (0110) plus a leftover digit, and the leftover is padded on the left to make 0001. The zeros do not change the value — 10110 and 00010110 are the same number — and the padding is what gives the last group a digit to be. Without it, the leftover single digit would have nothing to map to in the table.
- Is there any arithmetic in this conversion?
- No, and that is the interesting part. Because sixteen is a power of two, the boundary between the bases falls exactly every four binary digits, so the conversion is a regrouping rather than a calculation. Nothing is multiplied, nothing is added and nothing is carried; the digits are cut into fours and each group is looked up. That is the reason hexadecimal is used instead of some other compact notation, and it is why the grouping is printed beside the answer: the grouping is the method, shown rather than described.
- Why does one hex digit equal four bits and not three or five?
- Because four bits can hold exactly sixteen distinct values and a hexadecimal digit has exactly sixteen distinct symbols. Three bits would give only eight values, which is why octal pairs with three, and five bits would give thirty-two, which no common base uses. The match has to be exact for the regrouping to work without any carries, and only powers of two give that. It is also why a byte, being eight bits, is always exactly two hexadecimal digits.
- What is the longest binary number I can convert?
- Fifty-three digits, which is 9007199254740991 in decimal and fourteen hexadecimal digits after conversion. The ceiling is a property of how machines hold numbers exactly rather than a rule this page chose: past that width neighbouring whole numbers stop being distinguishable, so a longer input could not be converted faithfully. It is refused with a message rather than rounded, which matters because a rounded answer here would look like a perfectly ordinary hexadecimal value.
- Can I convert a fractional binary number?
- Not on this page. There is no binary point accepted and no hexadecimal fraction produced, because a fractional conversion needs an extra decision about how many places to keep and how to round the last one. Every page in this group works in whole numbers, so the same input is never accepted in one place and refused in another. Within that boundary the conversion is exact: any whole binary number up to the length limit maps to exactly one hexadecimal value with no rounding anywhere.
- Does capitalization matter in the answer?
- The answer is always printed in capitals — B2 rather than b2 — but the two are the same value and both are understood everywhere. Documentation, disassemblers and data sheets almost always use capitals, while CSS colour values are conventionally written in lower case, so a reader coming from either direction will recognise what they see. This page prints capitals for consistency with the rest of the family and because that is the convention in the material it is usually used alongside.
References
- Hexadecimal — the base-sixteen system, the digits beyond nine, and the relationship between one hexadecimal digit and four binary digits — Wolfram MathWorld (United States)
- Binary number — the base-two system and positional notation, which is what makes a fixed-width regrouping possible — Wolfram MathWorld (United States)
- Nibble — the four-bit group that one hexadecimal digit corresponds to, and the unit this conversion is carried out in — Wolfram MathWorld (United States)
- 教育部关于印发义务教育课程方案和课程标准(2022 年版)的通知——The fifth item in the annex list of this notice is the Mathematics Curriculum Standards for Compulsory Education (2022 edition); converting between binary, octal and hexadecimal is part of the information technology curriculum, and the wording of the standards and the grade-band breakdown are governed by that annex — 中华人民共和国教育部