Opening the calculator to do such tiny stuff appears annoying to me ,and I strongly believe in ths saying "the more you know,the better!" so here I am asking you how to convert hexadecimal to decimal.
Till that moment I use the following formula:
Hex: Decimal:
12 12+6
22 22+2*6
34 34+3*6
49 49+4*6
99 99+9*6
I get confused when I move on at higher numbers like C0 or FB
What is the formula(brain,not functional) that you're using?
The decimal value will be
in decimal notation, or
(32)10
.For
40h
in hexa we will have64
in decimal, forEOH
, we will have224
in decimal.In determining the decimal value of a specific index in a word, generalized for all bases:
where b is the base, i is the index in the word, and n is the numeric value at the index. Remember this by remembering that b,i,n = bin = short for binary.
Examples:
for base2 (binary) 1000, getting the value where the 1 is located:
b = base, ie base2: b=2
i = 0-based index within word, ie 1000, 1 is in 3th index, i=3
n = number listed in index, ie 1000, 3th index is 1, n=1
so, 2^3*1 = 8
for base10 (decimal) 900, getting the value where the 9 is located:
b=10, i=2, n=9 : 10^2*9 = 100*9 =900
for base16 (hexadecimal) 0x0f0, getting the value where the f is located:
b=16, i=1, n=15 (0-9,a-f,f=15) : 16^1*15 = 16*15 = 240
Note that this can be used to determine the value of each index in a word, then each value can be summed to determine the full word value.
e.g. 1001, from left to right (order doesn't matter in summation):
(2^3*1=8) + (2^2*0=0) + (2^1*0=0) + (2^0*1=1) = 9
I didn't find any of these helpful so here's my way: Turn it into two sets of binary numbers to represent each letter, then take the whole binary representation and convert to decimal
Example: AB
A / B
= 1010 / 1011 in binary
= 171 (128 + 0 + 32 + 0 + 8 + 0 + 2 + 1) in decimal
If you consider that hexadecimal is base 16, its actually quite easy:
Start from the least significant digit and work towards the most significant (right to left) and multiply the digit with increasing powers of 16, then sum the result.
For example:
0x12 = 2 + (1 * 16) = 18
0x99 = 9 + (9 * 16) = 153
Then, remember that A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15
So,
0xFB = 11 + (15 * 16) = 251
Memorize the decimal values of 20h, 40h, and so on, up to E0h. (I suppose you already know 100h.) Then get the decimal values if other numbers by adding or subtracting a number from 1 to 16.
That's not the formula.. that's not even somewhat like the formula...
The formula is:
X*16^y where X is the number you want to convert and y is the position for the number (from right to left).
So.. if you want to convert DA145 to decimal would be..
And you have to remember that the letter are:
A - 10
B - 11
C - 12
D - 13
E - 14
F - 15