Number Base
Convert between binary, decimal, hexadecimal, and octal, with a bit-by-bit view.
Input Value
🔢
Number Bases
Decimal (Base 10)
255Standard number system
Hexadecimal (Base 16)
FFCommon in programming
Octal (Base 8)
377Unix permissions
💻
Binary (Base 2)
Binary
1111 1111 8 bits
Bit Visualization
1
1
1
1
1
1
1
1
7
6
5
4
3
2
1
0
Each bit position represents 2^n. Value = Σ(bit × 2^position)
Powers of 2 Reference
2^0
1
2^1
2
2^2
4
2^3
8
2^4
16
2^5
32
2^6
64
2^7
128
2^8
256
2^9
512
2^10
1024
2^11
2048
2^12
4096
2^13
8192
2^14
16384
2^15
32768
Quick Reference
Binary: 0, 1
Octal: 0-7
Decimal: 0-9
Hex: 0-9, A-F
Features
- Convert between binary, decimal, hexadecimal, octal
- Bit visualization for binary
- Signed and unsigned integer support
- ASCII character encoding
- Color hex codes (#RRGGBB)
- Negative number representation (two's complement)
Common Use Cases
- Convert hex color codes to RGB
- Understand binary in programming
- Convert file permissions (octal) in Unix/Linux
- Decode hexadecimal memory addresses
- Work with bitwise operations
Number Base Systems
Number bases (or radixes) define how we represent numbers. Our familiar decimal uses 10 digits (0-9), but computers use binary (base-2), and programmers often use hexadecimal (base-16) and octal (base-8).
Common Number Bases:
- Binary (base-2): Uses 0 and 1, how computers store data (0b1010 = 10)
- Octal (base-8): Uses 0-7, common in Unix file permissions (0755)
- Decimal (base-10): Uses 0-9, human standard (42)
- Hexadecimal (base-16): Uses 0-9, A-F, compact binary (0xFF = 255)
Why Different Bases?
- Binary: Computers use binary—transistors are either on (1) or off (0)
- Hexadecimal: Each hex digit = 4 binary bits (nibble). Easier to read than long binary strings
- Octal: Each octal digit = 3 bits. Used in Unix permissions: 755 = 111,101,101 (rwxr-xr-x)
Common Use Cases:
- Colors: #FF5733 (hex) = rgb(255, 87, 51)
- Memory addresses: 0x7FFF5C9A (hexadecimal)
- File permissions: chmod 755 (octal: owner rwx, group r-x, others r-x)
- Bitwise ops: 0b1010 & 0b0110 = 0b0010 (AND operation)
- IPv6 addresses: 2001:0db8:85a3::8a2e:0370:7334 (hexadecimal)
Notation:
- Binary: 0b or 0B prefix (0b1010)
- Octal: 0 prefix (0755) or 0o (0o755)
- Hex: 0x or 0X prefix (0xFF) or # for colors (#FF00AA)
Examples
Valid - Color Hex to RGB
#FF5733 = 255, 87, 51 Valid - Binary to Decimal
0b1010 = 10 Valid - Unix File Permission
0755 (octal) = rwxr-xr-xFrequently Asked Questions
How do I convert hex color codes to RGB?
Split hex into 3 pairs (RR, GG, BB), convert each to decimal. #FF5733: FF=255, 57=87, 33=51 → rgb(255,87,51). Each hex pair is 0-FF (0-255). Use this tool for instant conversion.
What do Unix file permissions like 755 mean?
755 (octal) = 111,101,101 (binary). Each digit is user/group/others. 7(111)=rwx, 5(101)=r-x, 5(101)=r-x. So 755 = owner can read/write/execute, others can read/execute. Common: 644 (rw-r--r--), 755 (rwxr-xr-x).
Why do programmers use hexadecimal so much?
Hex is compact—1 hex digit = 4 bits. A byte (8 bits) = 2 hex digits. Binary 11111111 = FF (much shorter). Memory addresses, colors, and byte data are easier to read in hex than long binary strings.
What is two's complement for negative numbers?
Two's complement represents negative numbers in binary. Invert all bits and add 1. For -5 in 8-bit: 5 = 00000101, invert = 11111010, +1 = 11111011 (-5). Leftmost bit indicates sign (1=negative). Computers use this for arithmetic.
How do I count in binary?
0, 1, 10, 11, 100, 101, 110, 111, 1000... Same as decimal but only using 0 and 1. Each position is a power of 2: 1010 = (1×8) + (0×4) + (1×2) + (0×1) = 10.
💡 Tips
- Quick hex-to-decimal: F=15, A=10, B=11, C=12, D=13, E=14. #FF = 15×16 + 15 = 255
- Binary to hex: group 4 bits at a time. 11010101 = 1101,0101 = D5 (13 and 5 in hex)
- For colors, each channel (R,G,B) is 00-FF (0-255). #000000=black, #FFFFFF=white, #FF0000=red
- Common permissions: 644 (files), 755 (executables/dirs), 600 (private files), 777 (all access)