Hexadecimal
Most people know what decimal figures are, the majority also know what hexadecimal figures are.
For those few who do not:
The Hexadecimal figure-scope is a 16-base number-table,
and uses the first six letters of the alphabet to count upwards to 10.
As the value 10 in a 16-base table is in fact the value 16 in decimal,
i shall create a little table how decimal figures matches hexadecimal figures:
| Decimal | Hexadecimal |
| 00 | 00 |
| 01 | 01 |
| 02 | 02 |
| 03 | 03 |
| 04 | 04 |
| 05 | 05 |
| 06 | 06 |
| 07 | 07 |
| 08 | 08 |
| 09 | 09 |
| 10 | 0A |
| 11 | 0B |
| 12 | 0C |
| 13 | 0D |
| 14 | 0E |
| 15 | 0F |
| 16 | 10 |
If you learn the above table from the back of your head,
converting decimal figures to hexadecimal and back is a piece of cake, watch below neat tricks:
We define a #xx as decimal and $xx as hexadecimal.
Dec2Hex
To convert a decimal value to a hexadecimal value, you devide the figure by 16.
e.g.:#145 / #16 is #9.xxx, okay, snoop off the extra digits, #9*#16 = #144, #145 - #144 = #1.If we look up #1 in the Hex table it is identical to the decimal value.#9* $10 (which is still #16 in decimal) = $90. $90 + $01 = $91.The hexadecimal figure for #145 is $91.
Next example:#122 / #16 = #7.625, #7* #16 = #112, #122 - #112 = #10,#10 looked up in the Hex table above is $0A so #7*$10 = $70, $70 + $0A = $7A
If the decimal is lower than 16, simply use your memorised table-value.
Hex2Dec
To be able to calculate a Hexadecimal value to a decimal value,
you simply subtract the last digit from the figure and devide the figure by $10
(if the hex value is not $10 or lower), this amount you multiply by 16
and you add the converted last digit from the hex-table to it.
Okay so:
$233 → $233 - $03 = $230 → $230 / #10 = #23 → #23 *#16 = #368 → $03 = #03 → #368 +#03 = #371?
beeep
Wrong.
$230 / #10 is not #23 since after $90 we do not get $100 but $A0(and $B0, $C0 and 16 decimal digits after $F0 we get $100),so we miss #2 x #6 which is #12 * $10. why 6? A to F are six times a hexadecimal full-house.Okay, but why twice of 6? Because we have twice a $100 range
Again
$233 → $233 - $03 = $230 → $230 / #10 = #23 + #2*#6 = #12+#23=#35→ #35 *#16 = #560 → $03 = #03 → #560 +#03 = #563
Owh and what about binary to decimal?
Hmmz, it falls outside this scope actually.
But for the true nerds,
I’ll teach you the table of 15 and a quick conversion trick & this is all you get from me.
| Decimal | Binary |
| 00 | 0000 |
| 01 | 0001 |
| 02 | 0010 |
| 03 | 0011 |
| 04 | 0100 |
| 05 | 0101 |
| 06 | 0110 |
| 07 | 0111 |
| 08 | 1000 |
| 09 | 1001 |
| 10 | 1010 |
| 11 | 1011 |
| 12 | 1100 |
| 13 | 1101 |
| 14 | 1110 |
| 15 | 1111 |
Pick the binary figure you want to convert,
slice it into blocks of four 1′s from low-end to high end (from right to left),
each block can be up to value 15 which is value $0f in hexadecimal.
For any shortcoming of one, two or three binary figures paste the amount of missing zero’s to the high-end
e.g.:high-end →0b111010110110101011←low end0b11 1010 1101 1010 1011
pasting another 2 zero’s to the 0b11 high-end block:
| Binary | 0011 | 1010 | 1101 | 1010 | 1011 |
| Decimal | 03 | 10 | 13 | 10 | 11 |
| Hex | 03 | 0A | 0D | 0A | 0B |
The hex value for 0b111010110110101011 = $3ADAB
I can do the whole conversion trick from Hex2Dec again, but try to figure out yourself how i got #241067.
And is converting back to binary just as easy as converting to decimal?
Same routine, if you only have a simple calc some notepad and a pencil, this is the only way to go.
Besides a lot of calculators do not support very large bit-ranges.
Currently for me, this is the quickest trick (besides using the scientific part of the M$ calculator)