Web Design,Programming,Mobile,iOS/Android,GameDev,IT Businness,eCommerce,Social Media

Advertisement

Sunday, 19 May 2013

Binary numbers - Digital Logic explained

17:13


If you ever asked yourselves how computers think and logic then what you are asking is Digital Logic. There is an order and logic on how computers do all that stuff for us. If you are a computer science student then you know that in the very end computers only understand binary. 

You may write a very sophisticated software in any high level programming language, but in the very end everything is converted to machine language or binary. But why exactly binary ? What in reality is binary ? It's because electronic chips are made like that. They can only understand two states of behavior. TRUE/FALSE, ON/OFF, ACTIVE INACTIVE, SET/RESET. 

Whatever the situation these are called zeros and ones : 0101010001010101. Whenever there is 1 that means there is some input or value or something is happening, and whenever there is 0 that means its null or nothing. By combining different values of zeros and ones we can achieve interesting statements and chips can behave in a manner that we can command them to do some stuff for us. These zeros and ones are inserted in a digital circuit where they travel, and depending on the design of this circuit these numbers can flow in a way that they do something logical. 


These circuits are inside every electronic chip. Different chips have different circuit designs and a very large amount of zeros and ones travel inside these chips. The CPU has millions of millions of circuits that do different tasks. Billion of data travel inside these circuits. These circuits are designed in a way that they can do some logical operations. 

However we cannot understand digital circuits if we don't know what will live inside them. That is Binary. We must firstly get to know those zeros and ones. In the section below we describe everything about binary. We will learn how to understand binary numbers, convert them and do arithmetic operations just like we do with normal decimal numbers we use in our everyday life.

Binary Numbers

If we think, the numbers we use in everyday life are called decimals. Why like that ? Because they are formed of digits starting from 0 to 9. If we count from 0 to 9 we get 10 digits. Which means the decimals. On the other hand binary numbers consist of two digits, that is : 0 and 1. Every digital machine works on binary numbers. Binary numbers can be used to do operations just like decimals. We just need to follow some rules. For simplicity we will start converting decimals to binary numbers and vice-versa. Then we will do arithmetic operations with binary numbers just like we do with decimals.

The table below shows the corresponding binary combinations for decimal numbers from 0 to 9.

Decimal                  Binary

0                            0000
1                            0001
2                            0010
3                            0011
4                            0100 

5                            0101
6                            0110
7                            0111
8                            1000
9                            1001


We can prove this combination by converting any decimal number to binary or any binary number to decimal. When converting decimals to binary and vice-versa there is a rule we need to follow. For example let us take number 79 and convert to binary.

Decimals to binary

a ) Convert number 79 to binary

To convert any decimal number to binary we need to divide that number with the base of the numeral system we are converting to, in  this case binary which is 2. The base of binary is 2 because this numeral system consist of two digits. The base of decimal is 10 because this numeral system consist of 10 digits. When dividing if we get real number ( number with dot ) we simply avoid numbers after the dot and write only the integer. If the dividend is even the binary remainder will be 0 and if the dividend is odd the remainder is 1.

79 : 2 = 39.5 = 39 remains 1
39 : 2 = 19.5 = 19 remains 1
19 : 2 = 9.5 = 9 remains 1
9 : 2 = 4.5 = 4 remains 1
4 : 2 = 2 remains 0
2 : 2 = 1 remains 0
1 : 2 = 0.5 = 0 remains 1


The division goes till we reach 0. After we finish we write binary numbers in a counter way, like for this example the binary combination of number 79 is 1001111.

b ) Convert number 355 to binary

355 : 2 = 177.5 = 177           remains 1
177 : 2 = 88.5 = 88              remains 1
88 : 2   = 44                       remains 0
44 : 2   = 22                       remains 0
22 : 2   = 11                       remains 0
11 : 2   = 5.5 = 5                 remains 1
5 : 2     = 2.5 = 2                 remains 1
2 : 2     = 1                         remains 0
1 : 2     = 0.5  = 0                remains 1

The corresponding binary combination for decimal number 355 is 101100011.

c ) Convert number 4394 to binary

4394 : 2 = 2197                   remains 0
2197 : 2 = 1098.5 = 1098      remains 1
1098 : 2 = 549                    remains 0
594 : 2 = 274.5 = 274           remains 1
274 : 2 = 137                      remains 0
137 : 2 = 68.5 = 68              remains 1
68 : 2 = 34                         remains 0
34 : 2 = 17                         remains 0
17 : 2 = 8.5 = 8                   remains 1
8 : 2 = 4                            remains 0
4 : 2 = 2                            remains 0
2 : 2 = 1                            remains 0
1 : 2 = 0.5 = 0                    remains 1

The corresponding binary combination for decimal number 4394 is 1000100101010.

Binary to Decimal


To convert binary numbers to decimals we count the digits and power the base 2 with the counter. Then we do addition with the binary digit and result. We continue this for every binary digit and then we multiply the results. The end result is the corresponding decimal number to the binary number we are converting for. Take this formula for example.









The corresponding decimal number for binary 11011 is the number 27. Let us break in detail. As we said we mark the binary digits with counter. Then we power the base 2 with the actual counter. For this example that would be

1 x ( 2 x 2 x 2 x 2 ) = 16 = 1 x 16 = 16
1 x ( 2 x 2 x 2) = 8 = 1 x 8 = 8
0 x ( 2 x 2 ) = 4 = 0 x 4 = 0
1 x 2 = 2
1 x 1
= 16 + 8 + 0 + 2 + 1 = 27


Notice in the end if we power any number with 0 we get 1 that is why we wrote 1 x 1. When multiplying the results we get the final corresponding decimal number for the binary number we are converting for in this case number 11011 to decimal is 27.

Summary

There are different ways to convert numbers from decimal to binary and binary to decimal. We expect from you to explore. Binary numbers can be interesting especially if we know how to apply those values to Digital Circuits. In the next blog post we will explore arithmetical operations with binary numbers, just like we do with decimals. After that we will explore digital circuits, how to draw them and how binary numbers act upon these digital circuits. With that explored, we will have an overall understanding of electronic chips and inner workings of computers brain.

Suggested Article : Binary Numbers - Addition



Written by

Thank you for taking your time to browse through our blog. We try to build as much rich content base as we can. We focus in modern technologies, computer science design and business.

0 comments :

Post a Comment

 

© 2013 smartnoob . All rights resevered. Designed by Templateism