Why Is Binary Used in Electronics and Computers?

Updated on July 2, 2018
eugbug profile image

Eugene is a qualified control/instrumentation engineer Bsc (Eng) and has worked as a developer of electronics & software for SCADA systems.

Photo courtesy David Castillo Dominici / FreeDigitalPhotos.net
Photo courtesy David Castillo Dominici / FreeDigitalPhotos.net | Source

The Binary System

The binary numbering system, is the basis for storage, transfer and manipulation of data in computer systems and digital electronic devices. This system uses base 2 rather than base 10 which we are familiar with for counting in everyday life. By the end of this easy to understand article, you'll have a grasp of why binary is used in computers and electronics.

What is Decimal and Why Do We Use It?

The decimal, base 10 or denary numbering system is what we are familiar with in everyday life. It uses 10 digits. So you count 0,1,2,3,4,5,6,7,8,9 and when you get to 9, there is no symbol for the next number ten, so ten is represented by the digit 1 followed by 0 or "10", which really means "one ten and no units". Similarly when you get to 99, one hundred is represented by three digits 1, 0 and 0 i.e "100 which is interpreted as "one hundred, no tens and no units". So basically numbers are represented by a series of symbols in the units, tens, hundreds, thousands place etc. So for instance 134 means "one hundred, three tens and four units. The decimal system probably arose because we have 10 fingers on our hands which could be used for counting.

What is Binary and How Does it Work?

The binary system used by computers is based on 2 symbols; 0 and 1. So you count 0, 1, there is no symbol for 2, so 2 is represented by 10 or "one 2 and no units". In the same way that there is a units, tens, hundreds, thousands place in the decimal system, in the binary system there is a units, twos, fours, eights, sixteens place etc. in the binary system. So the binary and decimal equivalents are as below:

00000000 0

00000001 1

00000010 2

00000011 3

00000100 4

00000101 5

00000110 6

00000111 7 and so on

Counting in Binary and Decimal

Counting from 0 to 11111  binary = 31 decimal
Counting from 0 to 11111 binary = 31 decimal | Source

Why Do Computers Use Binary?

"A single switch can be on or off, enabling the storage of 1 bit of information. Switches can be grouped together to store larger numbers. This is the key reason why binary is used in digital systems."

Binary in Digital Computers and Electronic Devices

Numbers can be encoded in binary format and stored using switches. The digital technology which uses this system could be a computer, calculator, digital TV decoder box, cell phone, burglar alarm, watch etc. Values are stored in binary format in memory, which is basically a bunch of electronic on/off switches.
Imagine if you had a bank of 8 rocker switches just like in the image below. Each switch could represent 1 or 0 depending on whether it is turned on or off. So you think of a number and set the switches on or off to "store" the binary value of this number. If someone else then looked at the switches, they could "read" the number. In a computer, switches are implemented using transistors. The smallest memory configuration is the bit, which can be implemented with one switch. If 8 switches are added together you get a byte. The digital hardware is able to set the switches on and off (i.e. write data) and also read the state of the switches. In the conceptual image below, there are 8 switches and 2 to the power of 8 = 256 permutations or arrangements depending on whether a switch is on or off. If on represents 1 and off represents 0, the group of switches can represent any of the following values.


00000000 0 decimal
00000001 1 decimal
00000010 2 decimal
00000011 3 decimal
00000100 4 decimal
.
.
.
.
11111110 254 decimal
11111111 255 decimal

In an electronic device or computer, because of micro-miniaturization, billions of switches can be incorporated onto integrated circuits (IC), potentially allowing the storage and manipulation of huge amounts of information.

8 Bit "Memory" Made From a Gang of Rocker Switches

Conceptual idea of how the state of a bank of eight switches allows the "storage"  of 2 to the power of 8 =  256 possible numbers
Conceptual idea of how the state of a bank of eight switches allows the "storage" of 2 to the power of 8 = 256 possible numbers | Source

Decimal and Binary Equivalents

Binary
Decimal
 
 
0
0
1
1
10
2
11
3
100
4
101
5
110
6
111
7
1000
8
1001
9
1010
10
1011
11
1100
12
1101
13
1110
14
1111
15
10000
16

Floating Point, ASCII Code, Machine Code and Storage of Analog Data

Now in reality, an electronic system can be more complex. Numbers with decimal places are stored using a system called floating point and memory locations may be 32 or 64 bits wide.

Several types of data encoding systems are used by digital technology for representing data which is not specifically numbers. The data could be names and addresses in a database, temperature levels measured in a room, control data for an industrial robot or low level machine code which tells a microprocessor what to do.

A machine such as a computer, digital camera,, scanner etc cannot directly store non-numerical data from the real world in binary format. This type of data could be:

  • A person's name
  • Temperature in a room
  • An image from a digital camera or scanner.
  • Audio

The data must be encoded. In the case of a name or other text, the text is broken down into individual letters, numbers and other non alphanumeric characters (e,g, &*£$# etc) and a coding system called ASCII represents each character by a number from 0 to 127. This data is then stored in binary format as one or more bytes in memory, each byte being made up of individual bits, and each bit implemented using transistors. Similarly a voltage level from a temperature sensor is an analog signal and has to be converted to a number by a device called an analog to digital converter (ADC). These devices can have various resolutions and for a 16 bit converter, the signal level is represented by a number from 0 to 65535. A scanned image, digital photo or image created in a drawing package is stored as individual pixels and a byte of data is used for the red, green and blue intensity levels of each pixel.
What's the Difference Between Analog and Digital? explains this in more detail.

Not only are values or data stored in memory, but also the instructions which tell the microprocessor what to do. These instructions are called machine code. When a software program is written in a high level language such as BASIC, Java or "C", another program called a compiler breaks the program down into a set of basic instructions called machine code. Each machine code number has a unique function which is understood by the microprocessor. At this low level, instructions are basic arithmetic functions such as add, subtract and multiply.

Analog and Digital Signals

Digital signals in electronic circuitry are either high or low, representing a "1" or "0"
Digital signals in electronic circuitry are either high or low, representing a "1" or "0" | Source

ASCII Table Hex, Binary and Decimal Values

Table showing ASCII characters with their hexadecimal, binary and decimal values. Hexadecimal or "hex" is a convenient way of representing a byte or word of data. Two characters can represent 1 byte of data.

ASCII Code Table

ASCII code table. ASCII assigns a number from 0 to 127 to letters, numbers, non alphanumeric characters and control codes
ASCII code table. ASCII assigns a number from 0 to 127 to letters, numbers, non alphanumeric characters and control codes | Source

How to Convert Decimal to Binary Using the Remainder Method

If you don't have a calculator, you can easily convert a decimal number to binary. Successively divide the decimal number by 2 until the result is 0, noting each remainder. Then read the list of remainders from the bottom up.

The MSB or "most significant bit" is the leftmost bit in the result.
The LSB or "least significant bit" is the rightmost bit in the result.

Converting from decimal to binary
Converting from decimal to binary | Source

How to Convert Binary to Decimal

To convert from binary to decimal, multiply each digit in the binary number by successive powers of 2, and then add the results together

e.g. What is 1011010 in decimal?

Writing the binary number in a column with the MSB or leftmost bit at the top:

1 x 26 = 64
0 x 25 = 0
1 x 24 = 16
1 x 23 = 8
0 x 22 = 0
1 x 21 = 2
0 x 20 = 0 (20 = 1)

So 1011010 = 64 + 16 + 8 + 2 = 90 decimal

An Online Binary to Decimal to Hex Converter

This online converter lets you enter a binary, decimal or hexadecimal number which is instantly converted to the two other base systems:

Online Converter

George Boole and Boolean Algebra

Boolean algebra, developed by the British mathematician George Boole in the 19th century, is a branch of mathematics which deals with variables which can only have one of two states, true or false. In the 1930s Boole's work was discovered by the mathematician and engineer Claude Shannon, who realized it could be used to simplify the design of telephone switching circuits. These circuits originally used relays which could be either on or off, and the desired output state of the system, depending on the combination of states of the inputs, could be described by a Boolean algebraic expression. Boolean algebra rules could then be used to simplify the expression, resulting in a reduction of the number of relays required to implement a switching circuit. Eventually Boolean algebra was applied to the design of digital electronic circuitry as we will see below.

Digital Logic Gates - AND, OR and NOT

A digital state, ie high/low or 1/0 can be stored in a 1 bit cell in memory, but what if that data has to be processed? The most basic processing element in a digital electronic circuit or computer is a gate. A gate takes two or more digital signals and generates an output. There are three types of gates, AND ,OR and NOT (INVERT). In their simplest form, small groups of gates are available on a single IC. However a complex combinational logical function can be implemented using a Programmable Logic Array (PLA) and more sophisticated devices such as microprocessors are composed of millions of gates and memory storage cells.

For an AND gate, the output is true or high only when both inputs are true.

For an OR gate, the output is high if either or both inputs are true.

For a NOT gate or inverter, the output is the opposite state to the input.


Boolean algebraic expressions can be used to express what the output signal of a circuit should be, depending on the combination of inputs. The main operations in Boolean algebra are and, or and not. During a design process, the required value of an output for all the various permutations of input states can be tabulated in a truth table. The value '1' in the truth table means an input/output is true or high. The value '0' means the input/output is false or low. Once a truth table is created, a Boolean expression can be written for the output, simplified and implemented using a collection of logic gates.



So a typical Boolean expression with three independent variables A,B and C and one dependent variable D would be:

Y = A.B + C

This is read as "Y = (A and B ) or C"


Logic gates, AND, OR and NOT and their truth tables
Logic gates, AND, OR and NOT and their truth tables | Source
Truth table for a simple digital circuit.  Y = A.B + C
Truth table for a simple digital circuit. Y = A.B + C | Source

Questions & Answers

  • What are the applications of a binary encoding system?

    Binary encoding is a system of transmitting binary data over a link designed to handle text data. e.g. email.

    You can read more about it here:

    https://en.wikipedia.org/wiki/Binary-to-text_encod...

  • Why can't we use -1 in digital electronics?

    -1 or other negative numbers are normally implemented using two's complement. So to represent -1 in two's complement form, invert the bits and add 1:

    So 1 is 001

    Inverting the bits gives

    110

    Adding 1 gives

    111

    Remember this is just a conventional way of representing a negative number in a digital system so that arithmetic can be done and work out ok.

    So adding -1 and 1 gives -1 + 1 = 0

    or in binary 111 + 001 = 1000.

    Because only three bits are used, the 4th bit would be "unseen" by the digital system and the result in this example would be interpreted as 000 or zero.

    You can more about two's compliment here:

    https://en.wikipedia.org/wiki/Two%27s_complement

  • Which characteristic of a transistor is useful for digital counting and manipulation, and why?

    A transistor can behave as a controlled switch and form part of an elementary circuit element called a flip-flop. A flip-flop can store one bit of information, and in addition to other circuit elements, a higher level device called a binary counter can be implemented.

© 2012 Eugene Brennan

Comments

    0 of 8192 characters used
    Post Comment

    • profile image

      Nima 

      2 months ago

      The article was really helpful for my studies.. You did it very well . Thank you very much for the information

    • eugbug profile imageAUTHOR

      Eugene Brennan 

      4 months ago from Ireland

      Hi Chirayu,

      In the time before sophisticated computer graphics and when displays could only show text, alphanumeric characters were displayed on screen using a chip called a character generator ROM (Read Only Memory). This converted ASCII bytes in memory into a rectangular matrix of dots representing the character that circuitry in the computer and monitor could display.

      Here's some info on how Atari computers used to work.

      https://www.atariarchives.org/cgp/Ch02_Sec04.php

      Nowadays everything you see on screen is stored as a raster image in memory with three bytes for each pixel you see on screen. One byte is for red, one for blue and one for green. Depending on the value of the three bytes, you can get 16 million different shades of colours.

      Have a look at this tutorial which gives more detail.

      http://graphicdesign.spokanefalls.edu/tutorials/te...

    • profile image

      Chirayu 

      4 months ago

      Hello sir

      I have a question ....

      How computer imagine the design and shape of the binary code which we are writing ....

      For example :- I right eight in binary of so how computer imagine and design the shape of eight on the screen

    • profile image

      Kefas 

      7 months ago

      Great article, keep up with the brilliant work.

    • profile image

      Kiran 

      13 months ago

      U guys made my problem easy now I m topper in electronics first I got 60% now I am getting 99%

    • Robert Sacchi profile image

      Robert Sacchi 

      17 months ago

      It is a very good article that explains things very well. There is a simpler albiet less refined unrefined method of conversion. Decimal 27 to binary:

      32 16 8 4 2 1

      0 1 1 0 1 1 = 16+8+2+1 = 27

      Binary 1011010 to decimal:

      64 32 16 8 4 2 1

      1 0 1 1 0 1 0 = 64+16+8+2 = 90 Decimal

      5A Hexidecimal = 132 Octal

      Crude but effective.

    • wilderness profile image

      Dan Harmon 

      6 years ago from Boise, Idaho

      You explained this very well. Many years ago I experimented on programming in machine language - what a hassle! It didn't take long to move to something higher.

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, turbofuture.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://turbofuture.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)