Network mathematics · Local calculator

Decimal, Binary and Hexadecimal Converter

A protocol manual may print a field in hexadecimal while an inventory sheet expects decimal. Convert one unsigned integer across all three bases and check it against the field width.

Inputs

Result

Decimal
34525
Binary
1000011011011101
Hexadecimal
86DD
In this guide12 sections

Introduction

A protocol manual may print a field in hexadecimal while an inventory sheet expects decimal. Convert one unsigned integer across all three bases and check it against the field width.

Formula and calculation

Positional numeral conversion
value = Σ digit[i] × base^i; supported bases = 2, 10, 16

The converter parses an unsigned value, then formats that same value in binary, decimal, and hexadecimal. Input is limited to 128 bits; binary display does not imply a fixed word width.

base · 2, 10, or 16
radix of the input notation
digit[i] · base digit
digit at position i, counted from the right

Method and concepts

A numeral is a sum of digit values multiplied by powers of its base. Binary uses powers of two, decimal powers of ten, and hexadecimal powers of sixteen. Since sixteen is two to the fourth power, one hexadecimal digit represents exactly four binary positions.

  1. Select the base used by the source and enter its digits. Hexadecimal extends the digits 0–9 with A–F for values ten through fifteen.
  2. Read the equivalent values. If the destination field specifies a width, pad its left side with zeros to match that width.

Binary mathematics for network engineers diagram

  1. Host octet · 10101101
  2. AND mask · 11100000
  3. Network · 10100000
  4. OR wildcard · 10111111
For 173 with a /27 boundary, masking gives the block start 160. Setting the five host bits gives its inclusive end 191.

Worked examples

Decode the Ethernet type value 86DD

  1. Choose hexadecimal and enter 86DD. In four-bit groups the digits are 1000, 0110, 1101 and 1101.
  2. Apply the place values. The sum is (8 × 4096) + (6 × 256) + (13 × 16) + 13 = 34525.
  3. Choose decimal and enter 34525 to check the round trip. The result is the same 16-bit value, including both trailing D digits.

Binary mathematics for network engineers: Check the fourth octet of 192.0.2.173/27

  1. Decompose 173 into 128 + 32 + 8 + 4 + 1, giving 10101101. The fourth mask byte for /27 is 11100000, or 224.
  2. AND the two bytes to get 10100000, or 160. Complement 11100000 within eight bits to get wildcard 00011111, or 31.
  3. OR 10100000 with 00011111 to get 10111111, or 191. Count inclusively: 191 − 160 + 1 = 32, which matches 2^5 host-field patterns.

Reference table

Decimal, Binary and Hexadecimal Converter reference
HexFour bitsDecimal
000000
701117
810008
D110113
F111115

Reading the result

The displayed strings represent one magnitude. A two-byte field with value 1 can be printed as 0001 in hexadecimal. The leading zeros carry width information in the packet diagram while leaving the integer value unchanged.

Common mistakes

  • The digits 10 are valid in every supported base. Set the source base before interpreting them.
  • Keep the source byte order. Swapping the bytes 86 and DD produces a different value.

Frequently asked questions

How many hexadecimal digits fit in 128 bits?

Thirty-two hexadecimal positions cover 128 bits. Thirty-two F digits represent the maximum unsigned value, 2¹²⁸ − 1.

Can the same byte mean a negative number?

Yes. A signed field may define FF as −1 using two’s complement. As an unsigned integer FF is 255. Consult the field definition before interpreting a sign.

How do shifts relate to multiplication?

For an unsigned integer, shifting left one place multiplies it by two if the result still fits. A fixed-width register can lose its top bit on overflow.

Why does 255 + 1 become 256 on paper?

The exact sum has nine bits, 100000000. An eight-bit register needs an overflow indication or a defined wrapping rule to represent that operation.

Why do binary place values double from right to left?

Binary is base two. Each position is one power of two, so moving one place left multiplies its value by two.

How many bits are in a byte?

A byte contains eight bits. The byte can represent 256 distinct patterns, from 00000000 through 11111111.

Why is a subnet mask useful in binary?

A bitwise AND between an address and a contiguous mask preserves prefix bits and clears host bits, producing the network address.

Can hexadecimal shorten an IPv6 address without changing its value?

Yes. Hexadecimal groups four bits per digit, so it is a compact way to display 128-bit values. Zero compression changes notation, not the address bits.

What does two's complement do?

It is a common fixed-width representation for signed integers. The same bit pattern has a different interpretation depending on whether it is treated as signed or unsigned.

What does a bitwise AND do to a mask and address?

Each output bit is one only where both corresponding input bits are one. With a contiguous subnet mask, this preserves the prefix bits and clears host bits.

Why must a bitwise operation specify width?

Fixed-width operations constrain results to a chosen number of bits. Without a width, leading zeroes and overflow behavior can differ between mathematical integers and machine values.

How many bits does one hexadecimal digit represent?

One hexadecimal digit represents four binary bits. Two hex digits make one byte, which is why IPv6 hextets and MAC octets are naturally written in hex.

How do I convert a small binary number to decimal?

Multiply each bit by its power-of-two place value and add the results. For example, 10110₂ is 16 + 4 + 2 = 22₁₀.

Why group binary digits into fours when writing hexadecimal?

Each hex digit maps exactly to four bits. Grouping bits this way makes long address values shorter while preserving the exact bit pattern.

What is the difference between a signed and unsigned integer?

An unsigned fixed-width value treats all bits as magnitude. A signed representation reserves patterns for negative values, often using two's complement, so the same bit string can have a different decimal interpretation.

Does integer overflow wrap automatically in every calculator?

No. Behavior depends on the implementation and chosen width. A fixed-width calculator may reject an overflow, wrap, or report a carry, so inspect its documented range.

What does a bitwise OR do?

It sets an output bit when either corresponding input bit is one. It is often used to combine bit flags, while AND isolates bits and XOR highlights differences.

Further learning and references