HEXADECIMAL & DECIMAL Conversion


Byte - Bit - Nibble - Halfbyte ???

                    - B Y T E -       (Byte = 8-bit)
                -------------------
               MSD-NIBBLE|LSD-NIBBLE  (NIBBLE (Half Byte) = 4-bit)
                ---------|---------------------------------------------
  Bit NUMBER --- 7 6 5 4 | 3 2 1 0   < used for PC/PS-products
 (Bit NUMBER --- 0 1 2 3 | 4 5 6 7   < only for LARGE system products)
                ---------|---------------------------------------------
  Bit VALUE  --- 8 4 2 1 | 8 4 2 1   |  HEX  |  DECIMAL
                ---------|-----------|-------|-----------
                 0 0 0 0 | 0 0 0 0   |   0   |     0
                 0 0 0 0 | 0 0 0 1   |   1   |     1
                 0 0 0 0 | 0 0 1 0   |   2   |     2
                 0 0 0 0 | 0 0 1 1   |   3   |     3
                 0 0 0 0 | 0 1 0 0   |   4   |     4
                 0 0 0 0 | 0 1 0 1   |   5   |     5
                 0 0 0 0 | 0 0 1 1   |   6   |     6
                 0 0 0 0 | 0 1 1 1   |   7   |     7
                 0 0 0 0 | 1 0 0 0   |   8   |     8
                 0 0 0 0 | 1 0 0 1   |   9   |     9
                 0 0 0 0 | 1 0 1 0   |   A   |    10
                 0 0 0 0 | 1 0 1 1   |   B   |    11
                 0 0 0 0 | 1 1 0 0   |   C   |    12
                 0 0 0 0 | 1 1 0 1   |   D   |    13
                 0 0 0 0 | 1 1 1 0   |   E   |    14
                 0 0 0 0 | 1 1 1 1   |   F   |    15
                -----------------------------------------
                 0 0 0 1 | 0 0 0 0   |  10   |    16
                 0 0 0 1 | 0 0 0 1   |  11   |    17
                 0 0 0 1 | 0 0 1 0   |  12   |    18
                 0 0 0 1 | 0 0 1 1   |  13   |    19
                    ~         ~          ~        ~
                 1 1 1 1 | 1 1 0 1   |  FD   |   253
                 1 1 1 1 | 1 1 1 0   |  FE   |   254
                 1 1 1 1 | 1 1 1 1   |  FF   |   255  (max. for 1-byte)
                -----------------------------------------
    MSD = Most  Significant Digit
    LSD = Least Significant Digit


HEXADECIMAL & DECIMAL Conversion

From hex:  to DECIMAL

Locate each hex digit in it's corresponding column position and note the decimal equivalents. Add these to obtain the decimal value.

From decimal:  to HEX

  1.  Locate the largest decimal value in the table that will fit into the decimal number to be converted, and
  2.  note it's hex equivalent and hex column position.
  3.  Find the decimal remainder. Repeat the process on this and subsequent remainders.

 Examples:
 BINARY - HEX to DECIMAL conversion
  Binary value = 0000    0111    1010    1100    0100    0101  (3-bytes)
     HEX value = 0       7       A       C       4       5
  HalfByte # -> (6 ----- 5 ----- 4 ----- 3 ----- 2 ----- 1)
   (HB)          0   +   458.752+40.960+ 3.072 + 64  +   5  = 502.853
 DECIMAL to HEX - BINARY conversion
  Decimal value =  116.662.538  ->  6
                  -100.663.296 found in (HalfByte) HB #7
                  -------------
                    15.999.242  ->  F
                   -15.728.640 found in HB #6
                   ------------
                       270.602  ->  4
                      -262.144 found in HB #5
                      ---------
                         8.458  ->  2
                        -8.192 found in HB #4
                        -------
                           266  ->  1
                          -256 found in HB #3
                          -----
                            10  ->  0  set to 0 - because no match in HB #2
                          -----
                            10  ->  A  found in (HalfByte) HB #1
  HEX '6F4210A' =  BINARY 0110 1111 0100 0010 0001 0000 1010 (3,5 - Byte)
 +--------------------------------------------------------------------------------+
 |                                     WORD                                       |
 |--------------------------------------------------------------------------------|
 |                    HALFWORD                        |         HALFWORD          |
 |----------------------------------------------------|---------------------------|
 |             BYTE            |        BYTE          |     BYTE       |   BYTE   |
 |-----------------------------|----------------------|----------------|----------|
 |BITs   0123    |     4567    |    0123    |   4567  |  0123  | 4567  | 0123|4567| <- only LARGE System
 |---------------|-------------|------------|---------|--------|-------|-----|----|
 |BITs   7654    |     3210    |    7654    |   3210  |  7654  | 3210  | 7654|3210| <- PC/PS System
 |---------------|-------------|------------|---------|--------|-------|-----|----|
 |H|   Decimal   |H|  Decimal  |H|  Decimal |H|  Dec. |H| Dec. |H| Dec.|H| D |H|D |
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 | |      8      | |     7     | |     6    | |   5   | |  4   | |  3  | | 2 | |1 | <- Half-byte (nibble)
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |0|          0  |0|        0  |0|       0  |0|    0  |0|   0  |0|  0  |0| 0 |0| 0|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |1|  268.435.456|1| 16.777.216|1| 1.048.576|1| 65.536|1| 4.096|1|  256|1| 16|1| 1|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |2|  536.870.912|2| 33.554.432|2| 2.097.152|2|131.072|2| 8.192|2|  512|2| 32|2| 2|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |3|  805.306.368|3| 50.331.648|3| 3.145.728|3|196.608|3|12.288|3|  768|3| 48|3| 3|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |4|1.073.741.824|4| 67.108.864|4| 4.194.304|4|262.144|4|16.384|4|1.024|4| 64|4| 4|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |5|1.342.177.280|5| 83.886.080|5| 5.242.880|5|327.680|5|20.480|5|1.280|5| 80|5| 5|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |6|1.610.612.736|6|100.663.296|6| 6.291.456|6|393.216|6|24.576|6|1.536|6| 96|6| 6|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |7|1.879.048.192|7|117.440.512|7| 7.340.032|7|458.752|7|28.672|7|1.792|7|112|7| 7|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |8|2.147.483.648|8|134.217.728|8| 8.388.608|8|524.288|8|32.768|8|2.048|8|128|8| 8|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |9|2.415.919.104|9|150.994.944|9| 9.437.184|9|589.824|9|36.864|9|2.304|9|144|9| 9|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |A|2.684.354.560|A|167.772.160|A|10.485.760|A|655.360|A|40.960|A|2.560|A|160|A|10|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |B|2.952.790.016|B|184.549.376|B|11.534.336|B|720.896|B|45.056|B|2.816|B|176|B|11|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |C|3.221.225.472|C|201.326.592|C|12.582.912|C|786.432|C|49.152|C|3.072|C|192|C|12|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |D|3.489.660.928|D|218.103.808|D|13.631.488|D|851.968|D|53.248|D|3.328|D|208|D|13|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |E|3.758.096.384|E|234.881.024|E|14.680.064|E|917.504|E|57.344|E|3.584|E|224|E|14|
 |-|-------------|-|-----------|-|----------|-|-------|-|------|-|-----|-|---|-|--|
 |F|4.026.531.840|F|251.658.240|F|15.728.640|F|983.040|F|61.440|F|3.840|F|240|F|15|
 |---------------|-------------|------------|---------|--------|-------|-----|----|
 |       8       |      7      |     6      |    5    |    4   |   3   |  2  |  1 | <- Half-byte (nibble)
 +--------------------------------------------------------------------------------+


Powers of 2 and 16

m n  m and 16  n - m n  m and 16  n
0
1
2
3
0 1
2
4
8
- 32
33
34
35
8 4 294 967 296
8 589 934 592
17 179 869 184
34 359 738 368
4
5
6
7
1 16
32
64
128
- 32
33
34
35
9 68 719 476 736
137 438 953 472
274 877 906 944
549 755 813 888
8
9
10
11
2 256
512
1 024
2 048
- 40
41
42
43
10 1 099 511 627 776
2 199 023 255 552
4 398 046 511 104
8 796 093 022 208
12
13
14
15
3 4 096
8 192
16 384
32 768
- 44
45
46
47
11 17 592 186 044 416
35 184 372 088 832
70 368 744 177 664
140 737 488 355 328
16
17
18
19
4 65 536
131 072
262 144
524 288
- 48
49
50
51
12 281 474 976 710 656
562 949 953 421 312
1 125 899 906 842 624
2 251 799 813 685 248
20
21
22
23
5 1 048 576
2 097 152
4 194 304
8 388 608
- 52
53
54
55
13 4 503 599 627 370 496
9 007 199 254 740 992
18 014 398 509 481 984
36 028 797 018 963 968
24
25
26
27
6 16 777 216
33 554 432
67 108 864
134 217 728
- 56
57
58
59
14 72 057 594 037 927 936
144 115 188 075 885 872
288 230 376 151 711 744
576 460 752 303 423 488
28
29
30
31
7 268 435 456
536 870 912
1 073 741 824
2 147 483 648
- 60
61
62
63
15 1 152 921 504 606 846 976
2 305 843 009 213 693 952
4 611 686 018 427 387 904
9 223 372 036 854 775 808

Symbol Value
K (kilo) 1.024=2  10
M (mega) 1.048.576=2  20
G (giga) 1.073.741.824=2  30


Back to  Jump to TOP-of-PAGE

Please see the LEGAL  -  Trademark notice.
Feel free - send a Email-NOTE  for any BUG on this page found - Thank you.