Privatool
Guide6 min read

Number Base Converter Online — Binary, Octal, Decimal, Hex

Convert numbers between binary, octal, decimal, and hexadecimal instantly. See 8, 16, 32-bit representations and two's complement. Free online tool.

By Privatool Team·

Number base conversion is the process of expressing the same number in different positional numeral systems. While humans use base 10 (decimal), computers use base 2 (binary) internally, and programmers frequently work with base 16 (hexadecimal) and base 8 (octal).

The four common bases

Base Name Digits used Example
2 Binary 0, 1 1010
8 Octal 0–7 12
10 Decimal 0–9 10
16 Hexadecimal 0–9, A–F A

All four represent the same number: ten.

Why hexadecimal?

Hex compresses binary: each hex digit represents exactly 4 binary bits. A byte (8 bits) is always 2 hex digits. This makes hex much easier to read than raw binary for memory addresses, color codes, and binary file formats.

Binary:      1111 1010
Hex:         FA
Decimal:     250

Common uses by base

  • Binary — CPU registers, bitwise operations, network masks
  • Octal — Unix file permissions (chmod 755, chmod 644)
  • Decimal — All everyday numbers, IP addresses
  • Hexadecimal — Colors (#FF5733), memory addresses (0x7FFE), character codes, MAC addresses

Quick reference: 0–15

Decimal Binary Octal Hex
0 0000 0 0
1 0001 1 1
8 1000 10 8
9 1001 11 9
10 1010 12 A
15 1111 17 F

Two's complement for negative numbers

Computers represent negative numbers using two's complement in binary. For an 8-bit signed integer, -1 is 11111111 (255 unsigned). This is why parseInt('FF', 16) gives 255 in JavaScript, but the same byte in a signed context is -1.

How to convert number bases online

  1. Go to Number Base Converter
  2. Enter a number in any base field (binary, octal, decimal, or hex)
  3. All other fields update instantly
  4. See 8-bit, 16-bit, and 32-bit representations below

Converting by hand

Understanding the mechanism makes the tool's output verifiable rather than magic.

Decimal to binary — divide by 2 repeatedly, keep the remainders, read them bottom to top:

156 / 2 = 78 r 0
 78 / 2 = 39 r 0
 39 / 2 = 19 r 1
 19 / 2 =  9 r 1
  9 / 2 =  4 r 1
  4 / 2 =  2 r 0
  2 / 2 =  1 r 0
  1 / 2 =  0 r 1
                  -> 10011100

Binary to decimal — multiply each digit by its positional value and sum:

1 0 0 1 1 1 0 0
128 + 0 + 0 + 16 + 8 + 4 + 0 + 0 = 156

Binary to hex — group into fours from the right and convert each group:

1001 1100
   9    C   -> 0x9C

That last shortcut is why hex is used at all: one hex digit maps to exactly four bits, so the conversion needs no arithmetic.

Two's complement, worked through

Negative numbers have no minus sign in binary. Two's complement encodes them so that the same addition circuit handles both signs.

To represent −5 in 8 bits:

 5        = 0000 0101
invert    = 1111 1010   (one's complement)
add 1     = 1111 1011   = -5

The check is that 5 + (−5) should be zero:

  0000 0101
+ 1111 1011
= 1 0000 0000   -> the 9th bit overflows away, leaving 0000 0000

The leading bit acts as a sign indicator, which is why signed 8-bit values run from −128 to 127 rather than −127 to 127: there is one more negative value than positive, because zero occupies a slot on the positive side.

Where base confusion causes bugs

Leading zeros. In several languages a numeric literal beginning with 0 is octal. parseInt("08") returned NaN in older JavaScript engines for exactly this reason. Always pass an explicit radix: parseInt("08", 10).

Colour values. #FF5733 is three hex bytes — red 255, green 87, blue 51. Reading them as decimal produces nonsense.

File permissions. Unix modes are octal: chmod 755 means 111 101 101 in binary, which is read/write/execute for the owner and read/execute for everyone else. chmod 777 is 111 111 111 — full access for all, which is why it is a common security finding.

Overflow. An 8-bit unsigned value wraps from 255 to 0. This is the mechanism behind classic arcade-game score rollovers and, less charmingly, a whole category of security vulnerabilities.

Quick recognition

Prefix Base Example
0b Binary 0b1010 = 10
0o or leading 0 Octal 0o17 = 15
none Decimal 42
0x or # Hexadecimal 0x2A = 42

Frequently asked questions

Why do computers use binary at all?

A transistor is reliably either conducting or not. Distinguishing two states tolerates noise and voltage drift; distinguishing ten would need far tighter tolerances. Binary is the most robust encoding available in physical hardware.

Why hex rather than octal?

Modern architectures are built on 8-bit bytes, and one byte is exactly two hex digits. Octal groups bits in threes, which does not divide evenly into eight. Octal survives mainly in Unix file permissions, where three-bit groups are precisely what is needed.

What is the largest number in 8, 16, and 32 bits?

Unsigned: 255, 65,535, and 4,294,967,295. Signed (two's complement): −128 to 127, −32,768 to 32,767, and −2,147,483,648 to 2,147,483,647.

Can fractions be converted between bases?

Yes, by multiplying the fractional part repeatedly by the target base. Note that 0.1 in decimal is a repeating fraction in binary and cannot be represented exactly — the root cause of 0.1 + 0.2 !== 0.3 in floating-point arithmetic.

What does 0x mean?

It marks a hexadecimal literal in C-derived languages, so 0x10 is 16 rather than 10. The # prefix serves the same purpose in CSS colours.

Convert number bases free →

Share this article
#number base converter#binary to decimal#hex converter#binary converter#decimal to hex

Related Posts

Try our free tools

All tools run in your browser. Files never leave your device.

Explore free tools →