Hexadecimal Arithmetic Calculator Formula

Understand the math behind the hexadecimal arithmetic calculator. Each variable explained with a worked example.

Formulas Used

Sum Val

sum_val = a + b

Diff Val

diff_val = a - b

Prod Val

prod_val = a * b

Div Val

div_val = b != 0 ? a / b : 0

Mod Val

mod_val = b != 0 ? mod(a, b) : 0

Variables

VariableDescriptionDefault
aNumber A (decimal)255
bNumber B (decimal)16

How It Works

Hexadecimal Arithmetic

Hex Addition/Subtraction

Hex arithmetic works like decimal but in base-16. This calculator accepts decimal inputs (enter the decimal equivalent of your hex number) and displays results in decimal.

Conversions

  • Hex FF = Decimal 255
  • Hex 10 = Decimal 16
  • Hex A = Decimal 10
  • To convert between hex and decimal, use the Hex to Decimal converter.

    Worked Example

    Operations on 255 (FF in hex) and 16 (10 in hex).

    a = 255b = 16
    1. 01255 + 16 = 271 (hex: FF + 10 = 10F)
    2. 02255 - 16 = 239 (hex: FF - 10 = EF)
    3. 03255 × 16 = 4080 (hex: FF × 10 = FF0)
    4. 04255 / 16 = 15.9375
    5. 05255 mod 16 = 15 (hex: F)