Number Base Converter
- A decimal number converts to another base by repeated division: divide by the base, write down the remainder, and repeat with the quotient until it reaches zero. The remainders, read bottom to top, are the digits in the new base.
- 255 in decimal is 1111 1111 in binary (grouped in fours), 377 in octal and FF in hexadecimal.
- It needs 8 bits, which is 1 byte - the same count a computer would use to store it as an unsigned integer.
This number base converter changes a decimal number into another base, such as binary, octal or hexadecimal, and shows the result along with how many bits and bytes that value takes up. It works by repeated division: divide the number by the target base, write down the remainder, and repeat with the quotient until it reaches zero. The remainders, read bottom to top, are the digits in the new base. For example, 255 in binary is 1111 1111, which is octal 377, hexadecimal FF, 8 bits and 1 byte. The number 42 in binary is 10 1010, or octal 52, hexadecimal 2A, 6 bits and 1 byte. And 1,024 in binary is 100 0000 0000, or octal 2000, hexadecimal 400, 11 bits and 2 bytes.
Repeated division is the accepted standard for this kind of calculation because it is the direct, reliable way to express a decimal value in any other base: each remainder is exactly one digit of the result, and reading them bottom to top gives the correct number every time. The same method also tells you the size of the result. The bits needed are the position of the highest 1 bit, and the bytes are the bits rounded up to a multiple of 8, which is the same count a computer uses to store the number as an unsigned integer. On this page you will find the formula, step-by-step workings, worked examples and sources so you can check every result yourself.
Worked examples
255
255 in binary is 1111 1111 - octal 377, hexadecimal FF, 8 bits, 1 byte. (255)
| Binary | 1111 1111 |
| Octal | 377 |
| Hexadecimal | FF |
| Bits needed | 8 |
| Bytes needed | 1 |
42
42 in binary is 10 1010 - octal 52, hexadecimal 2A, 6 bits, 1 byte. (42)
| Binary | 10 1010 |
| Octal | 52 |
| Hexadecimal | 2A |
| Bits needed | 6 |
| Bytes needed | 1 |
1,024
1,024 in binary is 100 0000 0000 - octal 2000, hexadecimal 400, 11 bits, 2 bytes. (1024)
| Binary | 100 0000 0000 |
| Octal | 2000 |
| Hexadecimal | 400 |
| Bits needed | 11 |
| Bytes needed | 2 |
How base conversion works
Every base conversion from decimal follows one simple loop: divide the number by the new base, write down the remainder, and repeat with the quotient until the quotient reaches zero. The remainders, read bottom to top, are the digits of the number in the new base. That is the whole mechanism a number base converter automates — the division is the same whether you are heading to binary, octal, hexadecimal, or any other base.
Take 255 and convert it to binary. Divide 255 by 2: the quotient is 127 with a remainder of 1. Divide 127 by 2: quotient 63, remainder 1. Divide 63 by 2: quotient 31, remainder 1. Divide 31 by 2: quotient 15, remainder 1. Divide 15 by 2: quotient 7, remainder 1. Divide 7 by 2: quotient 3, remainder 1. Divide 3 by 2: quotient 1, remainder 1. Divide 1 by 2: quotient 0, remainder 1. The quotients have reached zero, so you stop. Reading the eight remainders bottom to top gives 1111 1111 — which is 255 in binary, written here as 8 bits, or 1 byte. The same number is 377 in octal and FF in hexadecimal.
The method does not change with the target base; only the divisor does. Converting 42 to binary divides by 2 each time and produces the remainders that read bottom to top as 10 1010 — 6 bits, 1 byte. In octal, 42 is 52; in hexadecimal, it is 2A. A larger example shows how the digit count grows: 1,024 in binary is 100 0000 0000, which is 11 bits and 2 bytes, while the same value is 2000 in octal and 400 in hexadecimal. Because octal and hexadecimal group bits neatly — three bits per octal digit and four bits per hexadecimal digit — those bases are often used as shorthand for long binary strings.
Two counts fall out of the result directly. The bits needed are the position of the highest 1 bit, and the bytes are the bits rounded up to a multiple of 8. That is the same count a computer uses to store the number as an unsigned integer, which is why these figures matter when you are sizing a field or checking a value against a fixed-width format.
When you check a conversion by hand, work the division from the bottom up and confirm the highest remainder is not zero — a leading zero would mean you divided one time too many. Reading the remainders in the wrong direction is the most common mistake, and it produces a plausible-looking but incorrect answer. The bottom-to-top rule is the one detail worth double-checking every time.
- 255: binary 1111 1111, octal 377, hexadecimal FF — 8 bits, 1 byte
- 42: binary 10 1010, octal 52, hexadecimal 2A — 6 bits, 1 byte
- 1,024: binary 100 0000 0000, octal 2000, hexadecimal 400 — 11 bits, 2 bytes
Binary, octal and hexadecimal
Computers work in base 2 because a bit has exactly two reliable states, on or off. Binary expresses those states directly, but long strings of 1s and 0s are hard for people to read and check. Octal (base 8) and hexadecimal (base 16) solve that by grouping bits: each octal digit stands for three bits, and each hex digit stands for four. That is why a number base converter so often shows binary, octal and hexadecimal side by side — they are compact shorthand for the same underlying bits.
The repeated-division method works for every base. Divide the decimal number by the base, write down the remainder, and repeat with the quotient until it reaches zero. The remainders, read bottom to top, are the digits in the new base. For base 2 the remainders are always 0 or 1; for base 16 they run 0 through 9 and then A through F for the values ten through fifteen.
Three worked examples show the pattern. The number 255 in binary is 1111 1111, which is octal 377 and hexadecimal FF — 8 bits, or 1 byte. The number 42 in binary is 10 1010, which is octal 52 and hexadecimal 2A — 6 bits, 1 byte. The number 1,024 in binary is 100 0000 0000, which is octal 2000 and hexadecimal 400 — 11 bits, 2 bytes.
The bit and byte counts follow a simple rule. The bits needed are the position of the highest 1 bit, and the bytes are the bits rounded up to a multiple of 8 — the same count a computer uses to store the number as an unsigned integer. So 42 needs 6 bits, which rounds up to 1 byte, while 1,024 needs 11 bits, which rounds up to 2 bytes.
- 255: binary 1111 1111, octal 377, hexadecimal FF — 8 bits, 1 byte.
- 42: binary 10 1010, octal 52, hexadecimal 2A — 6 bits, 1 byte.
- 1,024: binary 100 0000 0000, octal 2000, hexadecimal 400 — 11 bits, 2 bytes.
Bits and bytes
Once you have converted a number into binary, two more counts often come up: how many bits it needs and how many bytes that works out to. Both are simple to read off the binary result. The bits needed are the position of the highest 1 bit, and the bytes are the bits rounded up to a multiple of 8. That is the same count a computer uses to store the number as an unsigned integer.
Take 255. In binary it is 1111 1111. The highest 1 bit is in position 8, so 255 needs 8 bits, and 8 bits is already a multiple of 8, so it takes 1 byte. In octal that same number is 377, and in hexadecimal it is FF. Smaller numbers show the same rule. The number 42 in binary is 10 1010, which is octal 52 and hexadecimal 2A. Its highest 1 bit is in position 6, so it needs 6 bits. Rounding 6 up to a multiple of 8 gives 8, so 42 still takes 1 byte. A number can need fewer than 8 bits and still occupy a full byte.
Larger numbers cross the byte boundary. The number 1,024 in binary is 100 0000 0000, which is octal 2000 and hexadecimal 400. Its highest 1 bit is in position 11, so it needs 11 bits. Rounding 11 up to a multiple of 8 gives 16, so 1,024 takes 2 bytes. Notice that the bit count tells you where the top 1 sits, while the byte count tells you how much storage the value occupies once you round up to whole bytes.
This is why a number base converter is handy when you want to see the binary form that these bit and byte counts are read from. Convert the decimal value to binary first, find the leftmost 1, and count its position for the bits. Then round that bit count up to the nearest multiple of 8 for the bytes.
- 255: binary 1111 1111, octal 377, hexadecimal FF, 8 bits, 1 byte
- 42: binary 10 1010, octal 52, hexadecimal 2A, 6 bits, 1 byte
- 1,024: binary 100 0000 0000, octal 2000, hexadecimal 400, 11 bits, 2 bytes
Why binary is grouped in fours
Binary and hexadecimal look like different languages, but they are tied together by a simple structural fact: every four binary bits correspond to exactly one hexadecimal digit. That is why a number base converter usually presents binary output in groups of four rather than as one uninterrupted string of 1s and 0s. Once the bits are spaced into fours, you can read the hexadecimal value straight off the page without any further arithmetic.
The conversion itself still follows the standard rule. A decimal number converts to another base by repeated division: divide by the base, write down the remainder, and repeat with the quotient until it reaches zero. The remainders, read bottom to top, are the digits in the new base. When the target base is 16, each remainder is a value from 0 to 15, and the values 10 through 15 are written with the letters A through F. Because 16 is 2 multiplied by itself four times, each hexadecimal digit stands for a block of four bits, and that is the whole reason the grouping works.
The worked examples make the alignment visible. 255 in binary is 1111 1111, which groups as 1111 and 1111, and those two groups are F and F, giving hexadecimal FF; the same value is octal 377, 8 bits, 1 byte. 42 in binary is 10 1010, and padding the short group to four bits gives 0010 1010, which reads as 2 and A, matching hexadecimal 2A; that value is octal 52, 6 bits, 1 byte. 1,024 in binary is 100 0000 0000, which groups as 0100 0000 0000, or 4 and then 0, 0, matching hexadecimal 400; it is octal 2000, 11 bits, 2 bytes.
Bit and byte counts follow from the same structure. The bits needed are the position of the highest 1 bit, and the bytes are the bits rounded up to a multiple of 8, the same count a computer uses to store the number as an unsigned integer. So 42 needs 6 bits but occupies 1 byte, and 1,024 needs 11 bits but occupies 2 bytes. Grouping in fours also explains why hexadecimal is the compact shorthand of choice: two hex digits cover one byte exactly, so a byte never splits across a group boundary.
- 255: binary 1111 1111, octal 377, hexadecimal FF, 8 bits, 1 byte
- 42: binary 10 1010, octal 52, hexadecimal 2A, 6 bits, 1 byte
- 1,024: binary 100 0000 0000, octal 2000, hexadecimal 400, 11 bits, 2 bytes
FAQs
What is 255 in binary?
255 in binary is 1111 1111. The same value is written as 377 in octal and FF in hexadecimal. These are different notations for one number, not different numbers. Binary uses only 0 and 1, octal uses digits 0 through 7, and hexadecimal uses 0 through 9 plus A through F.
What is 42 in binary?
42 in binary is 10 1010. The same value is written as 52 in octal and 2A in hexadecimal. Each notation expresses the identical quantity using a different base. Binary is base 2, octal is base 8, and hexadecimal is base 16, so the digits and their length change while the value stays the same.
What is 1,024 in binary?
1,024 in binary is 100 0000 0000. The same value is written as 2000 in octal and 400 in hexadecimal. Because 1,024 is 2 to the tenth power, its binary form is a single 1 followed by ten zeros. The octal and hex forms are shorter ways to write that same value.
How many bits does 255 need?
255 needs 8 bits, or 1 byte. That is because 8 bits can represent 256 distinct values, from 0 through 255, and 255 is the largest of them. In binary, 255 appears as 1111 1111, with all eight bit positions set to 1.
How do you convert decimal to binary?
Divide by 2 repeatedly and read the remainders bottom to top. At each step, divide the number by 2, note the remainder (0 or 1), and continue with the quotient until it reaches zero. The remainders, read from the last one obtained back to the first, give the binary digits.
Why is hexadecimal used in computing?
One hex digit is exactly four bits, so it is a compact way to write binary. A byte of 8 bits maps to two hex digits, which is much shorter and easier to read than a long string of 0s and 1s. That makes hexadecimal convenient for displaying and checking binary values.