Try it

Result (hex)39
Result (decimal)57

Understand the result

What's going on

Memory addresses, color codes, register values - a lot of the numbers engineers work with day to day show up in hex, not decimal. Being able to do quick arithmetic directly in hex saves a constant back-and-forth conversion.

The formula

decimal(a) [op] decimal(b), converted back to hex

Show the derivation, mnemonic, and worked example

Build it up

Hex has sixteen digits - 0 through 9, then A through F standing in for 10 through 15. Add or subtract column by column exactly like decimal, except a column only carries once it passes 15, not 9. Everything else about long addition, subtraction, multiplication, and division carries straight over.

Worked example

Worked example

2A (42) + F (15)

42 + 15 = 57

57 in hex = 39