Number Base Converter: Binary, Hex and Decimal

Number Base Converter
DECIMAL VALUE
–
BINARY
–
OCTAL
–
HEXADECIMAL
–
DECIMAL (BASE 10)
–
Binary is the language of computers, hex is its compact shorthand: every 4 bits become one hex digit.

Binary, octal, decimal, and hexadecimal are four ways of writing the same number. Programmers constantly jump between them: colors are hex, file permissions are octal, and everything inside the machine is binary. Enter a number and its base above, and the converter shows all four representations at once.

How base conversion works

Every position in a number is a power of the base. Decimal 255 means 2×102 + 5×101 + 5×100. The same idea applies in any base:

Value = dn×basen + … + d1×base1 + d0×base0

Take hex FF. F equals 15, so the value is 15×161 + 15×160 = 240 + 15 = 255 in decimal. In binary that’s 11111111: eight ones, each worth a power of two from 128 down to 1.

Why hexadecimal exists

Hex is binary’s compact shorthand. Every 4 binary digits map to exactly one hex digit, so a 32-bit address like 11111111111111111111111111111111 becomes just FFFFFFFF. That’s why memory addresses, color codes like #EA580C, and MAC addresses are written in hex: eight characters instead of thirty-two.

The four bases side by side

BaseNameDigits usedCommon use
2Binary0, 1Digital circuits, bit flags
8Octal0–7Unix file permissions (e.g. 755)
10Decimal0–9Everyday counting
16Hexadecimal0–9, A–FColors, memory addresses

Converting by hand

To go from decimal to another base, repeatedly divide by the base and read the remainders backwards. Decimal 255 to binary: 255 ÷ 2 = 127 remainder 1, 127 ÷ 2 = 63 remainder 1, and so on down to 1 ÷ 2 = 0 remainder 1, giving 11111111. Going the other way, expand each digit times its positional power, as in the FF example above.

Bit grouping tricks

Because 16 = 24, converting between binary and hex needs no arithmetic at all: pad the binary to a multiple of 4 digits, split it into groups of 4, and replace each group with its hex digit (0000=0 through 1111=F). Octal works the same way with groups of 3, since 8 = 23. So 11111111 becomes 1111 1111, which is FF in hex and 377 in octal (011 111 111).

Reading hex color codes

Every color on a website is three bytes written in hex: red, green, blue, two digits each. The brand orange #EA580C means EA (234) red, 58 (88) green, 0C (12) blue. White is #FFFFFF (all channels maxed at 255), black is #000000 (all zero). Once you see the pattern, you can read any color code like a number: the higher the red pair, the warmer the color.

What this calculator doesn’t do

The converter handles whole numbers only: no fractions, no negative signs, and no floating-point formats. Extremely large numbers may lose precision because the underlying math uses JavaScript’s number type. For arbitrary-precision work, use a dedicated big-number library. If you only need one conversion, type the number and pick its base; the other three appear instantly.

Frequently asked questions

What is hexadecimal used for?

Hex is shorthand for binary: one hex digit stands for exactly 4 bits. You’ll see it in HTML color codes (#FF0000 is red), memory addresses, and cryptographic hashes.

How do I convert binary to hex quickly?

Group the bits in fours from the right, then swap each group for its hex digit: 0000=0, 0001=1, … 1010=A, 1111=F. So 10101111 becomes 1010 1111, which is AF.

What does 0x mean in front of a number?

The 0x prefix marks a number as hexadecimal in most programming languages: 0xFF means hex FF, or 255. Similarly, 0b marks binary and 0o marks octal in languages like Python.

Why do Unix permissions use octal?

Each permission (read, write, execute) is one bit, and three permissions per class make three bits: exactly one octal digit. So 755 means rwxr-xr-x: full rights for the owner, read and execute for everyone else.

Can letters be used in number bases?

Yes: any base above 10 borrows letters for the extra digits. Hex uses A through F for values 10 through 15. Higher bases (up to 36) continue through Z.

Is hex the same as decimal with letters?

No: the digits are the same characters, but the place values differ. Hex 10 is decimal 16, hex 100 is decimal 256. Same symbols, different positional weights.

References

Positional notation and radix: Radix — Wikipedia. Binary and hexadecimal details: Hexadecimal — Wikipedia.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top