Decimal to Binary Converter

Turn an ordinary base-10 number into the 1s and 0s a processor actually stores.

Type 156 into this converter and you get 10011100 back. That eight-digit string is not a translation for humans — it is closer to what the number actually looks like once it reaches a processor.

Why a computer only has two digits to work with

A transistor, the switch inside every chip, is reliable at exactly two states: on or off, roughly 0 or 5 volts depending on the chip. Building a circuit that reliably distinguishes ten different voltage levels for the ten decimal digits is possible, and it was tried — early machines experimented with decimal circuitry. It never scaled the way two-state switching did.

Binary, or base 2, uses only the digits 0 and 1, so each digit maps directly onto a transistor being off or on. Every number your computer stores, from a file size to a bank balance, is binary underneath, no matter which base you see on the screen.

Converting 156 by hand

Binary place values double as you move left: 1, 2, 4, 8, 16, 32, 64, 128. To convert 156, find the largest place value that fits and subtract it, then repeat. 156 − 128 = 28. 28 − 16 = 12. 12 − 8 = 4. 4 − 4 = 0.

So 156 = 128 + 16 + 8 + 4, which switches on the 128, 16, 8 and 4 place values and leaves the rest off, giving the byte 10011100. Adding those four numbers back up — 128+16+8+4 — confirms it: the total is 156.

A few conventions that trip people up

  • Leading zeros — A byte is usually written with all eight digits even when the leading ones are zero, so 5 is 00000101, not 101, once it is padded to a byte.
  • Bit order — The leftmost digit is the most significant bit — the biggest place value, 128 in a byte — not simply the first one you happen to type.
  • Byte size — Most systems group bits into bytes of eight. A number needing more than eight bits, such as 300, spills into a second byte.

Decimal to binary questions

Why is binary base 2 instead of base 10?

Because the switches inside a processor, transistors, are only reliable at two distinct states rather than ten. Base 2 maps a digit directly onto off and on, which base 10 cannot do in hardware nearly as cheaply.

How many bits do I need for a given decimal number?

Enough bits to cover the largest place value below the number. Eight bits, one byte, cover 0 to 255, and anything from 256 up to 65,535 needs two bytes, 16 bits.

What is the largest number a single byte can hold?

255, written as eight 1s: 11111111. That is because 128+64+32+16+8+4+2+1 adds up to 255, the maximum value once every bit in a byte is switched on.

Do negative numbers work the same way?

Not directly. Computers represent negative integers using a scheme called two’s complement, which flips and adjusts the bits rather than just writing a minus sign in front of the binary digits. Converting a negative decimal number needs that extra step.

Why do I sometimes see binary numbers padded with extra zeros?

Because memory is allocated in fixed-size chunks — a byte, a 16-bit word, a 32-bit word — so a small value like 5 is padded to 00000101 to fill a whole byte. The padding does not change the value, only how it is stored.

Cookie
We care about your data and would love to use cookies to improve your experience.