Skip to main content

🔢 Number Base Converter

Convert between binary/octal/decimal/hexadecimal

Binary (BIN)0b11111111
Octal (OCT)0o377
Decimal (DEC)255
Hexadecimal (HEX)0xFF

Number Base Converter Guide

The Number Base Converter supports conversion between four commonly used number bases: binary (BIN), octal (OCT), decimal (DEC), and hexadecimal (HEX). Select the input base type and enter a value, and the tool simultaneously displays the representation in all four bases.

A number base (or numeral system) is a fundamental concept of counting systems. In daily life we use decimal (base 10), while computers internally use binary (base 2). Programmers frequently need to convert between hexadecimal (memory addresses, color codes) and binary/decimal. This tool is a helpful assistant for learning computer fundamentals and everyday programming work.

Core Rules of Four Number Bases

【Binary BIN】Characters: 0,1   Base=2
Example: 1010(binary) = 10(decimal)
Uses: Computer low-level operations, bit manipulation, network masks

【Octal OCT】Characters: 0-7   Base=8
Example: 12(octal) = 10(decimal)
Uses: Linux file permissions (rwx=7), legacy Unix systems

【Decimal DEC】Characters: 0-9  Base=10
Example: 10 → Everyday counting system

【Hexadecimal HEX】Characters: 0-9,A-F  Base=16
Example: A(hex)=10(dec), FF(hex)=255(dec)
Uses: Color codes (#FF5733), memory addresses, extended ASCII

Practical Examples

📋
【Example 1】Decimal 255 to other bases Input: 255 in DEC mode BIN: 11111111 (8 ones) OCT: 377 HEX: FF Application: This is the maximum value of an 8-bit unsigned integer 【Example 2】Color code parsing CSS color #FF5733 R=FF(hex)=255(dec) G=57(hex)=87(dec) B=33(hex)=51(dec) Meaning: Orange-red 【Example 3】File permission interpretation Linux permission rwxr-xr-x = 755(octal) 7=111(bin)=rwx (all permissions) 5=101(bin)=r-x (read and execute) 5=101(bin)=r-x (read and execute) 【Example 4】Binary to decimal 1101(bin) = 1×8 + 1×4 + 0×2 + 1×1 = 13(dec)

Important Notes

💡
- Input values must conform to the character set rules of the selected base (e.g., binary can only contain 0 and 1) - Hexadecimal letters A-F are case-insensitive; the tool outputs uppercase uniformly - Supports prefix format recognition: 0b prefix=binary, 0o=octal, 0x=hexadecimal - Conversion precision depends on JavaScript's Number.MAX_SAFE_INTEGER (approximately 9×10¹⁵) - Negative numbers are stored in two's complement form in computers; this tool handles mathematical positive integer conversions

Application Scenarios

  • - Software development: Viewing variable values in hexadecimal/binary during debugging
  • - Web frontend: CSS color values (#RRGGBB) and RGB component conversion
  • - Network engineering: Binary analysis of subnet masks (255.255.255.0)
  • - Embedded development: Register configuration, bit field operations, port address settings
  • - Computer science education: Understanding how data is stored in computers

Why Computers Use Binary

Binary became the foundation of computing because it is the easiest to implement with physical devices — high voltage represents 1, low voltage represents 0 (or vice versa). The on/off state of transistors naturally corresponds to one bit of binary. Although multi-valued logic (such as ternary) is theoretically possible, two-state devices are the most stable and reliable.

Interesting fact: Octal and hexadecimal are essentially "shorthand" representations of binary numbers — every 3 binary digits correspond to 1 octal digit, and every 4 binary digits correspond to 1 hexadecimal digit. This is why they are both powers of 2 (2³=8, 2⁴=16), allowing perfect conversion to and from binary without precision loss.

Ad Slot