| | Trying to learn assembly... How do I convert a hexidecimal form to the decimal equivalent? |
|
|
|
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 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. 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.
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
Recent Queries:-
Keywords : convert, hexadecimal, decimal
Looking for convert, hexadecimal, decimal
|
|
![]() How Do I Convert Hexadecimal To Decimal? |
| ADD REPLY / Got an Opinion! | Remove these ADs! | RAPID SEARCH! | Free Web Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute more info. to help others. Ask your Doubts & Queries to get answers, So that "Together We can help others!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|