Professional Documents
Culture Documents
Hexadecimal and Binary Number System Basics For Embedded Programming
Hexadecimal and Binary Number System Basics For Embedded Programming
Hexadecimal and Binary Number System Basics For Embedded Programming
Register
News
Contact Us
Reviews
More
HOME EMBEDDED HEXADECIMAL AND BINARY NUMBER SYSTEM BASICS FOR EMBEDDED PROGRAMMING
FOLLOW US
Search ...
Posted By Umang Gajera Posted date: June 27, 2012 in: Embedded 5 Comments
To get started in Embedded programming following things need to be absolutely clear in our heads:
Email Address
Subscribe
This tutorial mainly deals with Hexadecimal & Binary Numbering Systems and how to inter-convert
them. This lays the foundation for bit level operations. A complete tutorial for bit level(or bitwise)
operations is located @ www.ocfreaks.com/tutorial-embedded-programming-basics-in-c-bitwiseoperations/.
OCFreaks.com
1.7Klikes
LikePage
Bethefirstofyourfriendstolikethis
In our case we have 5 digits hence our last power of 2 will be 24 with 20 begin the rst :
Order / Multiplication Factor(MF) 24
23
22
21
20
24
23
22
21
x1 =2 20 x1 =1
Sum
16+0+0+2+1 =19
x1 =16
x0 =0
x0 =0
First , Lets have a look at the conversion chart below for Decimal, Hexadecimal and Binary:
Decimal Hexadecimal Binary
0
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
10
1010
11
1011
12
1100
13
1101
14
1110
15
1111
From simple observation we can deduce the fact that : to convert any binary number to
hexadecimal we need to rst group the bits where each group contains 4 bits and then directly
replace that group with its equivalent hexadecimal from the above table. We start the grouping
from LSB i.e from right.
Also the binary representation of any hexadecimal symbol or digit has only 4 orders or weights
or multiplication factor associated. These are 23 , 22 , 21 and 20 or simply 8-4-2-1.
Consider a binary number : 1010101001110 , we can group it as 10-1010-0100-1110. Note that the
grouping into 4 starts from right side. Now the group on the extreme left has only 2 bits so we can
append zeros to keep things straight forward.
Hence we get : 0010-1010-0100-1110 , Now we replace each group by its Hex representation.
Binary =>
Hexadecimal => 2
Hence Hexadecimal_of(1010101001110) = 2A4E
Converting Hexadecimal to Binary: This is as simple as counting 1,2,3 :P. Simply replace each
Hexadecimal digit with its binary equivalent.. Thats it!
For eg. consider a Hex number say B39F1A
Replacing Each Hex digit with its binary equivalent we get :
Hexadecimal Digit
Binary equi. of each Hex Digit 1011 0011 1001 1111 0001 1010
Hence Binary_of(B39F1A) = 101100111001111100011010
Note that each digit is replaced with exact 4 bits .. i.e 3 is replaced by 0011 and not 11.
Replacing it with 11 will change the value of the number. Also this method is NOT applicable for
conversion from Decimal to binary.
Share this:
Share
Tags:
embedded
Like
programming
Tweet
tutorial
Share
Share
Share
Previous
GSKILL RipjawsX 4GB DDR3 1600Mhz CL9
Review
Next
Tutorial : Embedded programming basics in C
bitwise operations
3Comments
Recommend
OCFreaks!
Share
Login
SortbyNewest
Jointhediscussion
Stuaan2yearsago
ThankmanGreattutorialItwilldefinitelyhelpforbeginnerwhodoesn'tknowaboutthenumber
systemthisisonlybasicsbutIthinkitisimportantfornewerone
Reply Share
VasantPrabhu3yearsago
binarytodecimalconversiontheresatypoerror,thetableneedsacorrectionBitValueateach
Position2^3shouldbe0andfor2^4shouldbe1.
Reply Share
UmangGajera>VasantPrabhu3yearsago
Thanksfornotifyingaboutthetypo!:)Updatethetablewithcorrectvalues.
Reply Share
Subscribe d AddDisqustoyoursiteAddDisqusAdd
Privacy
Community
Register
Contact Us