converting between bases
Once you accept that 42, 0x2A, and 0b101010 are the same number wearing different clothes, the practical question is: how do you change its clothes by hand? Converting between bases is just bookkeeping, and three of the conversions you will do most often are easy enough to do in your head with a little practice.
Binary to hex (and back) is the easiest because four bits make one hex digit: group the bits into fours from the RIGHT, then translate each group. 1101 0011 splits into 1101 (which is 8+4+1 = 13 = hex d) and 0011 (which is 3), so it is 0xd3. Going the other way, expand each hex digit into its four bits. To convert binary to decimal, add up the place values of the 1 bits: 0b101010 has 1s in the 32, 8, and 2 places, and 32 + 8 + 2 = 42. To convert a decimal number to binary, the tidiest method is repeated division by 2: divide, write down each remainder, and read the remainders from bottom to top — 42 / 2 = 21 r0, 21 / 2 = 10 r1, 10 / 2 = 5 r0, 5 / 2 = 2 r1, 2 / 2 = 1 r0, 1 / 2 = 0 r1, reading bottom-up gives 101010.
In real programs you almost never convert by hand — printf with %x, %o, or by hand-rolled binary does it, strtol() parses a string in any base, and a debugger shows hex on demand. But understanding the mechanics keeps you from being fooled: knowing that 0x100 is 256, not 100, or that the high hex digit carries the top four bits of a byte, is the kind of fluency that makes reading memory dumps and bit masks feel natural instead of mysterious.
Decimal 42 -> binary by repeated /2: remainders bottom-up are 1,0,1,0,1,0 -> 101010. Group from the right into 10 1010, pad to 0010 1010, read as hex 0x2A.
Repeated division for decimal->binary; group-by-four for binary<->hex.
When grouping bits into hex nibbles, always group from the RIGHT (the low end) and pad the leftmost group with zeros; grouping from the left gives the wrong answer.