A question for you who work with hexadecimal frequently

decimal, hex

Solution

The way the brain works, it gets better if you do something a lot with it. Some people claim "it's like a muscle" but that's simplifying a bit too far.

So yeah, if you do hex conversions day in and out, you'll eventually be able to convert reasonably large numbers on sight, and you can do hex arithmetic without needing to convert into and out of decimal.

I once spent an evening memorizing the first 100 digits of pi.

So what?

Einstein is quoted as never memorizing any phone numbers. He said, "that's what I have a phone book for."

Same deal here. If you want to impress yourself and maybe your friends, sure, why not. But it's a mental exercise, not a truly useful skill.

In coding, unless you're working predominantly with assembler, you'll be using hex numbers only rarely. It makes sense to use hex numbers in contexts where those numbers will be bit-twiddled. e.g. You might mask a byte by AND-ing against 0xFF . Numbers associated with bitwise shifting, sign bits, OR and XOR may also make a lot of sense as hex. Numbers used for day-to-day arithmetic will usually be best expressed in decimal.

Once you're done with parlor tricks, one of the most important goals of programming is to write code that others (and maybe some day you) can read and understand easily. Using hex in the right places is good; using it in the wrong places is obfuscation and bad.

Problem

Whenever I work with hexadecimal values, I do the conversion (if needed) into decimal in my head or with the help of a converter. Well I was thinking, if you work long enough and get used to hexadecimal, do you just 'see' the value (whatever that means), as when reading decimal ? I mean are you after a while able to read base 16 values as easily as base 10 values ? When I write code with hexadecimal values, I do it because it looks sexy and badass (and sometimes because 8 bits fits into two digits, which helps sometimes), not because I feel somehow comfortable with 'em. That way I could know if there is any point in trying to get used to hexadecimal, to be some day able to work with them with ease.

Original source