Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

hexadecimal or decimal??????

Status
Not open for further replies.

yahaa

Member level 1
Joined
Oct 9, 2005
Messages
36
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,566
hi guys plz help me out

why do we use hexadecimal representation for programming the microprocessors and microcontrollers???
why dont we use decimal or octal or any other base such as 32 etc?
 

I may give you an answer "the other way round": I prefer to use decimal digits because it ist easier for human programmers to use decimal representation.

example: A common used size of a screen resolution is
1024 (decimal) x 768 (decimal) pixel

the same value in hexadecimal would be
0x400 (hex) x 0x300 (hex)


if you write some code, it might be easier to understand

for i := 1 to 1024 do {
for j := 1 to 768 do {

instead of
for i := 0x000 to 0x3ff do {
for j := 0x000 to 0x2ff do {
 

Hi !

We use hexadecimal format because it is simple and fast to convert and represent bits sequences (binary numbers) into hexadecimal numbers. Just separate the binary digits in groups of 4 (nibbles) and each nibble will be represented by a hexadecimal digit (from 0 to F).

0000 binary = 0 hexa
0001 binary = 1 hexa
0010 binary = 2 hexa
0011 binary = 3 hexa
0100 binary = 4 hexa
0101 binary = 5 hexa
0110 binary = 6 hexa
0111 binary = 7 hexa
1000 binary = 8 hexa
1001 binary = 9 Hexa
1010 binary = A hexa
1011 binary = B Hexa
1100 binary = C hexa
1101 binary = D hexa
1110 binary = E hexa
1111 binary = F hexa

Then to represent the byte 10010011 you just separate 1001 and 0011 and convert into two digit hexadecimal format: 93h , you notice that a byte can be represented by two hexadecimal digits.

As for computers, the binary format is better and decimal is better for humans, the hexadecimal is a mid term and can save digits when reprsenting large numbers, for example: 65535 decimal may be represented by FFFF hexa, saving one digit compared to decimal base.
 

mainly for 2 reasons :

1- you can manually convert the hexa format to its binary which is very attached to the nature of microcontrollers .. specially if you are dealing with a control word, in which u want to switch some pin on and some other off ...

2- it's shorter than binary .. as u can write a 16 bit # in only 4 digits .. and still have the binary nature so u can extract any binary stuff manually and easily.
 

Actually the question should be binary or decimal. Digital Devices understand only two conditions i.e. on or off; generally we represent on with 1 and off with 0. That's where binary comes into picture.

But using the 1,0 to represent big decimal numbers is difficult for human beings so we need some way to shorten the length of binary numbers and it should be easy to convert it to and from binary that's where hexadecimal come in.
 

but if saving digits and conversion were the case
why dont we use base 32 and take 5 nibbles together and find the equivalent???
 

hi
any machine understands only 1' ans 0's only.we group 4 bits into a nibble and represent in hex this saves the processor storage memory and easy understanding for us
 

Hi,
I use mixed radix in my programm:
for hardware control - hex; for loops, counters .. - decimal
Anyhow :D
 

Some kind of joke : Why Humans were designed for Hexadecimal number processing ?

Read **broken link removed**
 

yahaa said:
but if saving digits and conversion were the case
why dont we use base 32 and take 5 nibbles together and find the equivalent???
That's really good point the 4 bit nibble is related to trend followed in microprocessor design, i.e. you can't find 5, 10, 15... etc bit microprocessor.

4 bit nibble make it easy to deal with 8, 16, 32, 64 bit processor as they are multiple of 4.

Now you might ask why not 8 bit nibble? Go ahead and find 256 unique symbols to represent and remember each digit :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top