Number Base Converter

Number Base Converter

Convert between decimal, binary, octal, and hexadecimal

Number Bases Explained

Number bases are systems for representing numbers using a specific set of digits. While we use decimal (base 10) in everyday life, computers use binary (base 2) internally, and programmers frequently work with hexadecimal (base 16) and octal (base 8) for convenience. Understanding how to convert between these bases is essential for programming and computer science.

Common Number Bases

  • Decimal (Base 10) — Uses digits 0-9. This is the standard system for human counting and mathematics, likely because we have ten fingers.
  • Binary (Base 2) — Uses digits 0 and 1. Computers represent all data as binary values (bits). A group of 8 bits is a byte. For example, the decimal number 255 is written as 11111111 in binary.
  • Octal (Base 8) — Uses digits 0-7. Octal was more common in early computing and is still used for Unix file permissions (e.g., 755 for rwxr-xr-x).
  • Hexadecimal (Base 16) — Uses digits 0-9 and letters A-F (representing values 10-15). Hex is widely used for memory addresses, color codes (#FF0000), and representing binary data compactly. One hex digit represents exactly 4 bits.

Practical Applications

  • Memory debugging — Memory addresses and dumps are displayed in hexadecimal because it is more compact and readable than binary.
  • Color values — Web colors use hexadecimal (e.g., #4361EE) where each pair of digits represents the red, green, and blue components.
  • Bitwise operations — Low-level programming uses binary representations for flags, permissions, and efficient calculations.
  • File permissions — Unix/Linux file permissions are expressed in octal, where each digit represents read (4), write (2), and execute (1) permissions.
  • Cryptography — Hash values, encryption keys, and certificates are commonly displayed in hexadecimal for readability.