Home»Computers-and-Technology»Coverting Decimal To 8-Bits Binary And Vice Versa

Coverting Decimal To 8-Bits Binary And Vice Versa


Author:

Cisco Networking Basics

As a student at the Cisco networking academy program, I decided to write this blog about the basic networking info I learnt at Cisco for anyone interested and/or planning for a career in computers networking,or even anyone who just wanna know what is a router, switch,ip address, bandwidth,...all that. P.S: CISCO SYSTEMS INC. ARE THE WORLD LEADING NETWORKING COMPANY,JOIN THEIR ACADEMY PROGRAM FOR MUCH MORE INFO,LABS,E-LABS, EXAMS AND MORE..THIS BLOG IS NO ALTERNATIVE FOR THE COURSES.

There are many methods to convert decimal number into the corresponding binary. Only one famous method will be discussed here:

Converting decimal to binary:

The rules are as follows:

*You should start from the left most binary digit *If the decimal number is equal or greater than the place value (corresponding 2^number), then place the bit 1 and forward the difference to the next digit on the right *If the decimal number is less than the place value , then place the bit 0 and forward the number as it is to the next digit on the right

Example:

Suppose you got the decimal number 170:

- 170 is greater than 128(2^7) , so the left most bit is 1 , get the difference 170-128=42 -forward 42 to the next digit -42 is less than 64( 2^6), so place 0 and forward the number as it is (42) to the next step -42 is greater than 32(2^5), so place 1 and forward the difference which is 42-32=10 -10 is less than 16(2^4), so place 0 and forward the 10 as it is -10 is greater than 8(2^3) so place 1 and forward the difference which is 10-8=2 -2 is less than 4( 2^2) so place 0 and forward the 2 as it is -2 is equal 2( 2^1) so place a 1 and forward the difference which is 2-2=0 -0 is less than 1(2^0) so place a zero and you're done

so the decimal number 170 is equal to the binary number 10101010

NOTE THE FOLLOWING:

*The right most place value is 2^0

*Whenever you get a zero difference, all the next digits will be o's as zero will be less than 2^whichever number

*Only numbers from 0-255 can be represented by 8 digits binary .Numbers greater than 255 will be represented by more bits. For example: 256 is represented by 9 digits: 100000000. In general 2^n -1 gives you the largest number that can be represented by n digits. So in 8 digits binary, max. number is 2^8 -1= 255. In 9 digits binary, max.number is 2^9-1=511. So the range for 9 digits is from 256-511. Starting from 512 ,10 digits will be required.And so on............

Converting binary to decimal:

An example about this was already shown in the previous post.

00010110 = (1 x 24 = 16) + (0 x 23 = 0) + (1 x 22 = 4) + (1 x 21 = 2) + (0 x 20 = 0) = 22 (16 + 0 + 4 + 2 + 0)

This example shows that the binary number 00010110 is equal to the decimal number 22.

In general , all the 0 bits will add up to zero , so just ignore them and add the 1's. Here is another example:

10101010= (1*27=128) + (1*25 =32) + (1*23 = 8) + (1* 21 = 2) = 170

( we've already seen that 170 is = 10101010).

Cisco website

Cisco Academy Program


Rate : Coverting Decimal To 8-Bits Binary And Vice Versa


Rating: 0
Votes: 0
Visits: 23
                  


Review : Coverting Decimal To 8-Bits Binary And Vice Versa


Name:
*Email: 
*Review:   
*Rating:

Page loaded in :0.5355 seconds