Binary and Number Systems

Vaibhav • September 11, 2025

Computers are powerful machines, but they don’t think like humans. While we use decimal numbers (0–9) in everyday life, computers operate using a much simpler system: binary. In this article, we’ll explore how computers understand numbers, how binary compares to decimal, and how values are stored in memory. We’ll also walk through a simple demo that shows how to view the binary representation of a number using only the concepts we’ve covered so far.

Why Computers Use Binary

At the lowest level, computers are made of electronic circuits. These circuits can be either ON or OFF-nothing in between. This makes binary the perfect language for computers, because it has only two digits:

0 → OFF
1 → ON

Every piece of data in your computer-text, images, music, and even programs-is ultimately represented using just 0s and 1s. These binary digits are called bits.

The word “bit” is short for “binary digit.” A single bit can store one of two values: 0 or 1.

Decimal vs Binary

Humans use the decimal system, which is base 10. That means each digit in a number represents a power of 10. For example:

Decimal 245 = (2 × 100) + (4 × 10) + (5 × 1)

In binary (base 2), each digit represents a power of 2 instead:

Binary 1101 = (1 × 8) + (1 × 4) + (0 × 2) + (1 × 1) = 13

Here’s a quick comparison of the first few numbers in both systems:

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

Binary numbers get longer quickly, but they’re easy for computers to process because they only use two symbols.

How Numbers Are Stored in Memory

When you declare a number in C#, it’s stored in memory as a sequence of bits. For example:

int number = 5;

Behind the scenes, the number 5 is stored as:

00000000 00000000 00000000 00000101

That’s the 32-bit binary representation of 5. Each int in C# uses 4 bytes (32 bits) of memory. The rightmost bits represent the actual value, and the rest are leading zeros.

We haven’t covered data types in detail yet, but for now just know that int is used to store whole numbers, and it uses 32 bits of memory.

Simple Demo: Viewing Binary Representation

Let’s write a small program that asks the user for a number and shows its binary form. Since we haven’t introduced loops yet, we’ll keep it simple and only show the binary of the first digit the user types.

using System;

class Program
{
    static void Main(string[] args)
    {
        Console.Write("Enter a single-digit number: ");
        string input = Console.ReadLine();

        if (input.Length > 0)
        {
            char digit = input[0];
            int asciiValue = (int)digit;
            string binary = Convert.ToString(asciiValue, 2);

            Console.WriteLine("Character: " + digit);
            Console.WriteLine("ASCII value: " + asciiValue);
            Console.WriteLine("Binary (of character): " + binary);
        }
    }
}

This program asks the user to enter a number. It then takes the first character they typed, converts it to its ASCII value (a number), and then shows the binary representation of that number.

If the user types 5, the output might look like:

Character: 5
ASCII value: 53
Binary (of character): 110101

This isn’t the binary of the number 5-it’s the binary of the character '5'. That’s okay for now. We’ll learn how to convert strings to actual numbers in the next chapter.

When working with user input, always treat it as a string first. Convert it only when you’re ready and confident the input is valid.

Why Binary Matters

Understanding binary helps you appreciate how computers work at a low level. It also prepares you for topics like:

  • Bitwise operations (coming later)
  • Memory usage and optimization
  • Data encoding and file formats

Even though you won’t write binary code directly, knowing how it works gives you a deeper understanding of what your programs are doing behind the scenes.

The ASCII code for the letter A is 65, which is 1000001 in binary. Every character you type is stored as a number in memory.

Binary in Everyday Technology

Binary isn’t just for numbers. It’s used to represent everything in a computer:

  • Text is stored using character encodings like ASCII or Unicode
  • Images are stored as binary pixel data
  • Audio is stored as binary waveforms
  • Programs themselves are compiled into binary instructions

All of this is possible because binary is simple, reliable, and easy for hardware to process.

Summary

In this article, you learned how computers use binary to represent numbers and data. You now understand:

  • Why computers use binary instead of decimal
  • How binary numbers work and how they compare to decimal
  • How numbers are stored in memory using bits
  • How to display the binary representation of characters using C#

Binary is the language of computers. Even though you’ll mostly write code in C#, knowing how binary works gives you a solid foundation for understanding how your programs run. In the next article, we’ll introduce object-oriented concepts-starting with a gentle teaser of what objects and classes are.