Nov 8, 2009

How Do I Convert Hexadecimal To Decimal?

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > Assembler and Delphi

How Do I Convert Hexadecimal To Decimal?

Angela
Trying to learn assembly...

How do I convert a hexidecimal form to the decimal equivalent?

Notice from BuffaloHELP:
Topic title modified.

Comment/Reply (w/o sign-up)

BuffaloHELP
Would you like to know it by hand so that you can calculate it anywhere or would you like to have a reference so that you can look it up?

The detailed converting technique can be summarized here http://www.permadi.com/tutorial/numHexToBin/index.html

Online conversion calculator can be found here http://www.statman.info/conversions/hexadecimal.html

The basic idea is this: when we count as decimal world (Base10) we don't "carry the number" until the 10th count. That is, by simpler words, we don't add to the next digit place until all 9 boxes are filled (counted). Why only 9? ZERO is not filled with anything. The amazing discovery of digit ZERO is for another story, but for counting it is very important. Assuming you understand the concept and importance of ZERO we continue...

Let's say you have 16 items. You have 10 boxes to fill in Base10 where each box is numbered from ONE to NINE. The box marked ZERO is omitted. You start to fill in and you notice that all nine boxes are filled with 6 items still in your hands. To make it easier, you empty out NINE boxes, add one more item from your hands to 9 items taken out and place it on the side. You've just counted 10 items and you continue to fill empty boxes with remaining items in your hands. This is what we call the "carry the one" and add the remainder. Therefore we get the usual number 16--ONE complete set was filled and still had 6 left over.

This "carry the one" does not happen in Base16 until the box number 15 (counting from ZERO to FIFTEEN will result in 16 counts, counting formula = (15 - 0) + 1 OR (n2-n1)+1 ). So you don't "carry the one" until 16th count. The number 17 means "carry the one" and still have remainder of 1. This is represented as 11 in Base16. 20 is represented as 14 in Base16.

What's up with letters? Since counting only consists of a single digit representation, letters A, B, C, D, E, F were added as digits beyone 10 in Base10 world. So what we understand as 11 in decimal would be A in hexadecimal. It's like having 16 fingers smile.gif

A quck counting exercise you can do at home:
Use both hands and one foot to count objects. To make it easier mark your toes with letters A thru E. When you count up to letter F, instead of counting, write it as "1" on a piece of paper. laugh.gif Do try this exercise only if you want to...

Basice decimal to hexadecimal calculation by hand:
Pick a decimal. If decimal is larger than 16, divide decimal (d) by 16. Take the integer of dividend (h) and multiply by 16. Subtract this result from decimal (d) and find the remainder. Match the remainder as Base16.

d = 100
100 / 16 = 6.25
6 * 16 = 96
100 - 96 = 4 (hex for 4 is 4)
result = 64 Base16

So to convert from hexadecimal to decimal, all you have to do is multiply 16 with second digit and to left, plus the remainder. For example:
hexadecimal (h) = 5A
16 * 5 = 80
A in decimal = 10
80 + 10 = 90 in decimal

I hope this helped.

 

 

 


Comment/Reply (w/o sign-up)

FeedBacker
How do I convert Hexidecimal to Decimal
How Do I Convert Hexadecimal To Decimal?

This technique works for any number base. A number base is also called a 'Radix';

X is the number we are converting to the new radix.
Digits is an array of bytes that will hold the result.
The digits will be in reverse order, so, we'll have to reverse the
Contents of Digits when we're done.
[code]
Len := 0;
Repeat
Q := X div Radix;
are := X mod Radix;
Digits[Len] := are;
Len := Len + 1;
X := Q;
Until X = 0;

If Len > 1 then
Begin
I := 0;
J := Len - 1;
repeat
B1 := Digits[I];
Digits[I] := Digits[J];
Digits[J] := B1;
Inc(I);
Dec(J);
until I >= J;
End;

[/code]

Let's test the theory:

7F23 => ? in Radix 10 (radix 0a)

7F23 div 0A = CB6
7F23 mod 0A = 7 Digits[0] = 7

CB6 div 0A = 145
CB6 mod 0A = 4 Digits[1] = 4

145 div 0A = 20
145 mod 0A = 5 Digits[2] = 5

20 div 0A = 3
20 mod 0A = 2 Digits[3] = 2

3 div 0A = 0
3 mod 0A = 3 Digits[4] = 3

Digits contains {74523}
Reversing Digits yields {32547}

I hope this helps.

All The best,
:Flubbo.

-reply by flubbo

Comment/Reply (w/o sign-up)

(G)MathsPro
General Formula for Dec to Hex
How Do I Convert Hexadecimal To Decimal?

I managed to work out something using Bases 10 and 2, 2 bases I know well.

I got THIS:

Base x, place value p, number value (in Base x) q, and  number value (in base 10) V,

V = q((x^p)/x)

Of  course, this formula requires you to break down the values into their respective place values.

Theory in test: My calculator showed me 45 in Base 16 is 69 in Base 10. Let's try this out...

5((16^1)/16)

=5(16/16)

=5(1)

=5

4((16^2)/16)

=4(256/16)

=4(16)

=64

64+5

=69

Correct!

Hope this will work!

-reply by MathsPro

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


Searching Video's for convert, hexadecimal, decimal
See Also,
advertisement


How Do I Convert Hexadecimal To Decimal?

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com