Computer ScienceBasicsbeginner

Binary Number System Explained for Beginners

Why computers use 0 and 1, how binary place values work, how to convert binary to decimal and back by hand, and what bits and bytes are.

Published
TL;DR – Quick Answer

The binary number system is a base-2 system that uses only two digits, 0 and 1. Each place is worth twice the place to its right: 1, 2, 4, 8, 16 and so on. To convert binary to decimal, add the place values where there is a 1, so 1011 is 8 + 2 + 1 = 11. To convert decimal to binary, divide by 2 again and again and read the remainders from bottom to top. Computers use binary because their circuits have two states, off and on.

On This Page

The binary number system writes every number using only two digits: 0 and 1. It is called base 2. Our everyday numbers use ten digits, 0 to 9, and are called base 10 or decimal.

Computers store everything in binary: numbers, text, images and the programs themselves. This page explains place values first, then shows how to convert binary to decimal and decimal to binary by hand, with worked examples. You can check every answer with our number system converter.

First, how decimal place values work

You already use place values without thinking. Take the number 352:

  3        5        2
hundreds  tens     ones
 100       10       1

352 = 3 x 100 + 5 x 10 + 2 x 1

Each place is worth 10 times the place to its right: 1, 10, 100, 1000. That is why decimal is called base 10.

Binary place values

Binary works the same way, but each place is worth 2 times the place to its right:

Place value:  128   64   32   16    8    4    2    1
Power of 2:   2^7  2^6  2^5  2^4  2^3  2^2  2^1  2^0

Each digit can only be 0 or 1. A 1 means "count this place". A 0 means "skip it".

Tip: Learn the row 1, 2, 4, 8, 16, 32, 64, 128 by heart. Almost every binary question in exams and placement tests uses it.

Binary to decimal: how to convert by hand

Steps:

  1. Write the binary number.
  2. Under each digit, write its place value, starting with 1 on the right.
  3. Add the place values that sit under a 1.

Example 1: 1011

Binary:       1    0    1    1
Place value:  8    4    2    1

1011 = 8 + 0 + 2 + 1 = 11

Example 2: 110010

Binary:       1    1    0    0    1    0
Place value:  32   16   8    4    2    1

110010 = 32 + 16 + 2 = 50

Example 3: 11111111

Binary:       1    1    1    1    1    1    1    1
Place value: 128   64   32   16   8    4    2    1

11111111 = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

255 is the largest number you can store in 8 bits. This number will come up again when we talk about bytes.

Decimal to binary: how to convert by hand

There are two common methods. Use whichever feels easier.

Method 1: divide by 2

  1. Divide the number by 2. Write down the remainder (0 or 1).
  2. Divide the quotient by 2 again. Write down the remainder.
  3. Repeat until the quotient is 0.
  4. Read the remainders from bottom to top.

Convert 13:

13 / 2 = 6   remainder 1
 6 / 2 = 3   remainder 0
 3 / 2 = 1   remainder 1
 1 / 2 = 0   remainder 1

Read upwards: 1101
So 13 = 1101 in binary

Check: 8 + 4 + 0 + 1 = 13. Correct.

Convert 25:

25 / 2 = 12  remainder 1
12 / 2 = 6   remainder 0
 6 / 2 = 3   remainder 0
 3 / 2 = 1   remainder 1
 1 / 2 = 0   remainder 1

Read upwards: 11001

Check: 16 + 8 + 1 = 25. Correct.

Common mistake: Reading the remainders from top to bottom. For 13 that gives 1011, which is 11, not 13. Always read upwards.

Method 2: take away the biggest place value

  1. Find the biggest place value that fits in your number.
  2. Put a 1 there and subtract it.
  3. Move to the next place. Put 1 if it fits in what is left, otherwise 0.

Convert 45:

Place value Fits in what is left? Digit Left over
32 45, yes 1 45 - 32 = 13
16 13, no 0 13
8 13, yes 1 13 - 8 = 5
4 5, yes 1 5 - 4 = 1
2 1, no 0 1
1 1, yes 1 0

Read the digit column from top to bottom: 45 = 101101.

This method is quick for small numbers once you know the place values.

Counting from 0 to 10 in binary

Decimal Binary Decimal Binary
0 0 6 110
1 1 7 111
2 10 8 1000
3 11 9 1001
4 100 10 1010
5 101

Notice that every power of 2 (2, 4, 8) is a 1 followed by zeros, just as 10, 100 and 1000 are in decimal.

Bits and bytes

  • A bit (binary digit) is a single 0 or 1. It is the smallest unit of data.
  • A nibble is 4 bits.
  • A byte is 8 bits.

With n bits you can make 2^n different patterns:

Bits Different values Range (unsigned)
1 2 0 to 1
4 16 0 to 15
8 (1 byte) 256 0 to 255
16 65,536 0 to 65,535
32 4,294,967,296 0 to 4,294,967,295

This is why an int in Java, which is 32 bits, has a fixed range. Java's int also stores negative numbers, so its range is -2,147,483,648 to 2,147,483,647. Our variables and data types guide explains these sizes.

Storage sizes build on bytes. Memory and many operating systems use steps of 1024: 1 KB is 1024 bytes, 1 MB is 1024 KB, and so on. Hard disk makers often use steps of 1000 instead, which is why a "1 TB" disk shows a little less space on your computer.

Binary addition

Binary addition follows four simple rules:

0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10   (write 0, carry 1)

Add 1010 (10) and 0111 (7):

carry:  1 1 1
          1 0 1 0
        + 0 1 1 1
        ---------
        1 0 0 0 1

10001 is 16 + 1 = 17, and 10 + 7 = 17. Correct.

Other number systems you will meet

System Base Digits Example for 45 Where you see it
Binary 2 0, 1 101101 Inside every computer
Octal 8 0 to 7 55 Linux file permissions such as 755
Decimal 10 0 to 9 45 Everyday life
Hexadecimal 16 0 to 9, A to F 2D Colour codes such as #FF5733, memory addresses

Hexadecimal is popular because one hex digit stands for exactly 4 bits. So one byte is always two hex digits, from 00 to FF. Try conversions between all four with the number system converter.

Check your answers with a small Java program

You can write the "divide by 2" method in code. Java also has built-in methods that do the same job.

public class BinaryDemo {
    static String toBinary(int n) {
        if (n == 0) return "0";
        String bits = "";
        while (n > 0) {
            bits = (n % 2) + bits;
            n = n / 2;
        }
        return bits;
    }

    static int toDecimal(String bits) {
        int value = 0;
        for (char c : bits.toCharArray()) {
            value = value * 2 + (c - '0');
        }
        return value;
    }

    public static void main(String[] args) {
        System.out.println(toBinary(13));
        System.out.println(toBinary(25));
        System.out.println(toDecimal("1011"));
        System.out.println(toDecimal("11111111"));
        System.out.println(Integer.toBinaryString(45));
        System.out.println(Integer.parseInt("101101", 2));
    }
}

Output:

1101
11001
11
255
101101
45

toBinary adds each remainder to the front of the string, which is the same as reading the remainders upwards. toDecimal reads left to right and doubles the running total at each step, then adds the new digit.

Practice questions

Convert by hand, then check with the binary to decimal converter:

  1. 1001 to decimal (answer: 9)
  2. 1100100 to decimal (answer: 100)
  3. 6 to binary (answer: 110)
  4. 156 to binary (answer: 10011100)
  5. 101 + 110 in binary (answer: 1011, which is 11)

Quick revision

  • Binary is base 2 and uses only 0 and 1.
  • Place values double from right to left: 1, 2, 4, 8, 16, 32, 64, 128.
  • Binary to decimal: add the place values under each 1.
  • Decimal to binary: divide by 2 and read the remainders upwards.
  • 1 byte = 8 bits = 256 values, from 0 to 255.

To see how binary text works, try the text to binary converter. To learn how the computer manages the programs built on all these bits, read what is an operating system.

Frequently Asked Questions

What is the binary number system in simple words?
It is a way of writing numbers with only two digits, 0 and 1. Each position is worth double the position to its right, instead of ten times as in our normal decimal numbers.
How do you convert binary to decimal?
Write the place values 1, 2, 4, 8, 16 and so on under the digits, starting from the right. Add the place values that sit under a 1. For example, 1101 is 8 + 4 + 1 = 13.
How do you convert decimal to binary?
Divide the number by 2, write down the remainder, and repeat with the quotient until it becomes 0. Read the remainders from the last one to the first. For example, 13 gives remainders 1, 0, 1, 1, so 13 is 1101.
What is the difference between a bit and a byte?
A bit is a single binary digit, 0 or 1. A byte is a group of 8 bits. One byte can store 256 different values, from 0 to 255.
Why do computers use binary?
A computer's circuits are built from transistors that are either off or on. Two states map neatly to two digits, 0 and 1, which makes the hardware simple and reliable.

Want to Build Your Career in Java Full Stack with AI?

Join CodeBegun and train with working industry engineers — See the Java Full Stack course in Hyderabad

Apply for Demo Class →
Siva Prasad Galaba
Founder, CodeBegun · Staff Engineer

Founder of CodeBegun. 15+ years building Java systems at companies like Crunchyroll. Teaches Java, Spring Boot and system design the way the industry actually works, and mentors students through projects, mock interviews and placement preparation.

Technically reviewed by CodeBegun Technical TeamLast reviewed 5 December 2026 LinkedIn
Chat with us