Binary / Hex / Octal Converter

Convert numbers between binary, decimal, hex and octal.

Overview

Converts numbers bidirectionally between Binary (Base 2), Octal (Base 8), Decimal (Base 10), and Hexadecimal (Base 16) formats with bit length indicators.

Formula & Calculation Method

Target_Base = parseInt(Input_String, Source_Radix).toString(Target_Radix)

Parses positional notation with powers of base n, supporting integer representations up to 64-bit precision.

Worked Example: Converting Decimal 255 to Binary and Hexadecimal

Inputs: Decimal Value = 255 (Base 10)

  • Hexadecimal conversion (255 / 16 = 15 remainder 15): 'FF' (Base 16)
  • Binary conversion (powers of 2: 128+64+32+16+8+4+2+1): '11111111' (Base 2)
  • Octal conversion (255 / 8 = 31 remainder 7): '377' (Base 8)

Summary: Decimal = 255 | Hex = FF | Binary = 11111111 | Octal = 377

Common Use Cases

  • Embedded Systems Programming: Inspect microprocessor register bitmasks and GPIO pin configurations.
  • Network Subnetting: Convert IP addresses and subnet masks between binary bits and decimal notation.
  • Color Code Parsing: Decode 24-bit hex RGB color codes into individual 8-bit channel integers.

Frequently Asked Questions

Why is hexadecimal so popular in computer science?

Because 16 is 2^4; exactly two hex digits represent one 8-bit byte, making it compact and easy to align with binary memory.

What is the two's complement of a binary number?

A mathematical operation to represent negative numbers in binary: invert all bits and add 1.

What is an octal number?

A base-8 number system using digits 0 to 7; frequently used for Unix file permissions (e.g. chmod 755).

Related Calculators & Tools