Number Base Converter preview

Number Base Converter

Convert numbers between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) systems.

Key features

  • Binary/Octal/Decimal/Hex
  • Live conversion
  • Hex letter support
  • Copy results

Guide

Number base conversion is the process of expressing a value in one positional numeral system using a different base. The four most common bases in computing and mathematics are binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Every programmer, electrical engineer, and computer science student encounters these systems regularly. This guide explains how each base works, the conversion methods between them, and practical situations where each base is the right choice. Decimal is the system you use every day. It has ten digits: 0 through 9. Each position in a decimal number represents a power of 10. The number 5207 means 5 times 1000, plus 2 times 100, plus 0 times 10, plus 7 times 1. This positional value concept applies to every base. The only thing that changes is the number of available digits and the power each position represents. The decimal system almost certainly evolved because humans have ten fingers, making ten a natural grouping. Binary uses two digits: 0 and 1. Each position represents a power of 2. The binary number 1101 means 1 times 8, plus 1 times 4, plus 0 times 2, plus 1 times 1, which equals 13 in decimal. Computers operate in binary because electronic circuits have two stable states: on and off, high voltage and low voltage. Every piece of data your computer processes, from text to video to software instructions, is ultimately represented as sequences of 1s and 0s. Binary numbers get long quickly. The decimal number 255 is 11111111 in binary, eight digits for what decimal handles in three. This is why programmers rarely write raw binary for large values. They use octal or hexadecimal as shorthand notations that map cleanly to binary because 8 and 16 are both powers of 2. Octal uses eight digits: 0 through 7. Each octal digit corresponds to exactly three binary digits. The octal number 17 equals binary 001 111, which is decimal 15. Octal was historically important in computing when systems used architectures with word sizes divisible by 3 (such as 12-bit, 24-bit, and 36-bit machines). Today, octal appears most commonly in Unix/Linux file permissions. The permission value 755 means the owner can read, write, and execute (7 = 111 in binary), while group and others can read and execute but not write (5 = 101 in binary). The chmod command on Linux and macOS uses octal numbers to set file permissions, making octal knowledge relevant for any system administrator or developer working on Unix-based systems. Hexadecimal uses sixteen digits: 0 through 9 and A through F, where A represents 10, B is 11, C is 12, D is 13, E is 14, and F is 15. Each hexadecimal digit maps to exactly four binary digits. This makes hex the preferred shorthand for binary data in modern computing. The hex value FF equals binary 1111 1111, which is decimal 255. A single byte (8 bits) is always representable as exactly two hex digits, making hex ideal for displaying memory contents, color values, MAC addresses, and cryptographic hashes. Converting from decimal to any other base uses repeated division. To convert decimal 200 to binary, divide 200 by 2 repeatedly and record the remainders. 200 divided by 2 is 100 remainder 0. 100 divided by 2 is 50 remainder 0. 50 divided by 2 is 25 remainder 0. 25 divided by 2 is 12 remainder 1. 12 divided by 2 is 6 remainder 0. 6 divided by 2 is 3 remainder 0. 3 divided by 2 is 1 remainder 1. 1 divided by 2 is 0 remainder 1. Reading the remainders from bottom to top gives 11001000. The same method works for any target base. To convert 200 to hex, divide by 16: 200 divided by 16 is 12 remainder 8, 12 divided by 16 is 0 remainder 12 (which is C). Reading bottom to top gives C8. Converting from any base to decimal uses the positional value formula. Multiply each digit by its positional power and sum the results. For hex 2F3: 2 times 256 (16 squared) plus 15 times 16 (F is 15) plus 3 times 1 equals 512 plus 240 plus 3, which is 755 in decimal. This method works for any source base. For binary 101010: 1 times 32 plus 0 times 16 plus 1 times 8 plus 0 times 4 plus 1 times 2 plus 0 times 1 equals 42 in decimal. Converting between binary and hex is straightforward because each hex digit is exactly four binary digits. Group the binary number into chunks of four starting from the right, padding with leading zeros if needed. Binary 10110111 becomes 1011 0111, which is B7 in hex. Going the other direction, replace each hex digit with its four-bit binary equivalent. Hex A3 becomes 1010 0011. This direct mapping is why hex is so popular in programming contexts. Converting between binary and octal follows the same principle with groups of three. Binary 10110111 becomes 010 110 111 (padded with a leading zero), which is 267 in octal. Octal 52 becomes 101 010 in binary. The three-bit grouping makes octal less convenient than hex for modern 8-bit byte architectures, which is why hex has largely replaced octal in most programming contexts. Converting between octal and hexadecimal has no direct shortcut. The standard approach is to convert through binary as an intermediate step. Convert the octal number to binary (each octal digit to three bits), then regroup the binary digits into four-bit chunks and convert to hex. For example, octal 375 becomes binary 011 111 101, regrouped as 0 1111 1101, which is hex FD. Going through binary adds a step, but the process is entirely mechanical and quick with practice. Fractional numbers in different bases follow the same positional logic but with negative powers. In decimal, 0.75 means 7 times 0.1 plus 5 times 0.01. In binary, 0.11 means 1 times 0.5 plus 1 times 0.25, which equals 0.75 in decimal. Not all decimal fractions convert to finite binary fractions. The decimal value 0.1 in binary is 0.0001100110011... repeating infinitely. This is the root cause of floating-point precision issues in computing. Programming languages use prefixes to distinguish number bases in source code. In C, Java, JavaScript, Python, and many other languages, 0b or 0B indicates binary (0b1101), 0o or 0O indicates octal (0o17), and 0x or 0X indicates hexadecimal (0xFF). Numbers without a prefix are decimal. Some older C code uses a leading zero for octal (017), which is a common source of bugs when someone writes 010 expecting decimal 10 but gets octal 8. JavaScript's strict mode and modern versions address this by requiring the explicit 0o prefix for octal. Color codes in web development use hexadecimal extensively. The CSS color #3A7BFF breaks down to 3A for the red channel (58 in decimal), 7B for green (123), and FF for blue (255). Understanding hex lets you read and adjust color values directly. Need a slightly darker blue? Change FF to E0. Want to convert an RGB value of 128, 64, 32 to hex? Convert each component: 128 is 80, 64 is 40, 32 is 20, giving #804020. CSS also supports shorthand hex colors where each channel is one digit: #F00 expands to #FF0000 (pure red). The alpha channel in 8-digit hex colors (#3A7BFFCC) adds transparency using the same hex representation. Memory addresses and debugging use hexadecimal as the standard representation. When you see a memory address like 0x7FFF5FBFF8A0, that is a 48-bit value expressed as 12 hex digits. Debuggers, hex editors, and memory dump utilities all display data in hex because it is compact, maps directly to binary, and aligns neatly with byte boundaries. Each pair of hex digits is one byte, making it easy to count bytes and identify boundaries. A hex dump displays 16 bytes per line, with each byte shown as two hex digits, alongside the ASCII character representation. This format is the standard way to inspect binary files, network packets, and raw disk data. Networking relies on hexadecimal for MAC addresses (48 bits, displayed as six pairs like A4:C3:F0:12:34:56) and IPv6 addresses (128 bits, displayed as eight groups of four hex digits like 2001:0db8:85a3:0000:0000:8a2e:0370:7334). Understanding hex is essential for network configuration and troubleshooting. Subnet masks, when expressed in CIDR notation, map directly to binary representations that show which bits identify the network and which identify the host. Cryptographic hashes produce fixed-length hexadecimal strings. An MD5 hash is 32 hex digits (128 bits). A SHA-256 hash is 64 hex digits (256 bits). When you verify a file download by comparing its hash to a published value, you are reading hexadecimal. Each character represents 4 bits of the hash output. Hash values are displayed in hex rather than decimal because hex is more compact and maps directly to the binary output of the hashing algorithm. Bitwise operations in programming work at the binary level but are often expressed in hex for readability. A bitmask like 0xFF00 is clearer than its decimal equivalent 65280 and more compact than its binary form 1111111100000000. Bitwise AND, OR, XOR, and shift operations are fundamental to low-level programming, device driver development, protocol implementation, and performance optimization. Understanding binary representation is a prerequisite for using these operations effectively. A left shift by 1 bit doubles a value. A right shift by 1 bit halves it (for unsigned integers). AND with a mask extracts specific bits. OR with a mask sets specific bits. XOR flips specific bits. ASCII and Unicode character encoding maps characters to numeric codes that are commonly displayed in hex. The letter A is 0x41 (decimal 65). A space is 0x20 (decimal 32). URL encoding uses hex: %20 represents a space, %3A represents a colon. Understanding these hex values helps when debugging encoding issues, parsing binary protocols, or working with raw data streams. UTF-8 encoding uses variable-length byte sequences (1 to 4 bytes) where the binary pattern of the leading bits indicates the byte count, making binary comprehension essential for understanding text encoding at the byte level. Signed integers in binary use a representation called two's complement. In an 8-bit two's complement system, the values range from -128 to 127. The highest bit is the sign bit: 0 for positive, 1 for negative. The number -1 is represented as 11111111 in 8-bit binary (0xFF in hex). The number -128 is 10000000 (0x80). To negate a number in two's complement, invert all bits and add 1. For example, 5 in 8-bit binary is 00000101. Inverting gives 11111010. Adding 1 gives 11111011, which represents -5. Two's complement is the standard for signed integers in virtually all modern processors. Understanding it prevents confusion when debugging signed arithmetic, reading memory dumps, or working with binary protocols. Floating-point numbers also have a binary representation defined by the IEEE 754 standard. A 32-bit float has 1 sign bit, 8 exponent bits, and 23 mantissa bits. A 64-bit double has 1 sign bit, 11 exponent bits, and 52 mantissa bits. This is why floating-point arithmetic can produce surprising results. The decimal value 0.1 cannot be represented exactly in binary floating-point, just as 1/3 cannot be represented exactly in decimal. When you see that 0.1 + 0.2 equals 0.30000000000000004 in JavaScript, the cause is binary representation limitations. Special values include positive and negative infinity, negative zero, and NaN (not a number), each with specific bit patterns. Base 64 encoding is another numbering system used extensively in computing, particularly for encoding binary data as printable ASCII text. Base64 uses 64 characters (A-Z, a-z, 0-9, +, /) to represent 6-bit groups of data. It appears in email attachments (MIME encoding), data URIs in HTML and CSS, JWT tokens, and API authentication headers. Every 3 bytes of binary data becomes 4 Base64 characters, resulting in approximately 33% size increase. Base64 is not encryption. It is a reversible encoding used for data transport compatibility. Binary-Coded Decimal (BCD) is a hybrid system where each decimal digit is represented by its 4-bit binary equivalent, but the digits are not combined into a single binary number. The decimal number 42 in BCD is 0100 0010, which is different from the pure binary representation of 42 (101010). BCD is used in financial calculations, digital clocks, and other applications where decimal precision is important and binary floating-point rounding errors are unacceptable. Some processors include BCD arithmetic instructions. Number base conversion has applications in data compression, error detection codes, and digital electronics. Compression algorithms work with binary data directly. CRC (Cyclic Redundancy Check) and checksum calculations operate on binary representations. Digital circuit design uses binary logic gates and truth tables. The ability to move fluently between decimal, binary, hex, and octal is a core skill in all of these fields. Common conversion mistakes include miscounting positional values (forgetting that positions start at power 0, not power 1), confusing octal and hex prefixes in code, dropping leading zeros in hex bytes (writing A instead of 0A for a byte value), and misapplying two's complement rules. Another frequent error is performing arithmetic in the wrong base, such as adding 0x10 and expecting 10 when the result is actually 16 in decimal. The WebRecast number base converter eliminates these errors by handling conversions instantly and showing the result in all four bases simultaneously. For manual practice, memorize the hex values 0 through F and their 4-bit binary equivalents. Once you can convert single hex digits to binary and back without thinking, larger conversions become a matter of applying that knowledge digit by digit. Hex 0 is 0000, 1 is 0001, 2 is 0010, 3 is 0011, 4 is 0100, 5 is 0101, 6 is 0110, 7 is 0111, 8 is 1000, 9 is 1001, A is 1010, B is 1011, C is 1100, D is 1101, E is 1110, and F is 1111. This sixteen-entry lookup table is the most useful thing a programmer can memorize for working with low-level data. Powers of 2 are worth memorizing up to at least 2^16 (65536). The sequence is: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536. These values appear constantly in programming contexts. 1024 bytes is a kilobyte (technically a kibibyte). 65535 (2^16 minus 1) is the maximum value for a 16-bit unsigned integer. 2147483647 (2^31 minus 1) is the maximum 32-bit signed integer. Recognizing these numbers immediately tells you about the binary structure behind them. Data sizes in computing use powers of 2 and are expressed in bytes. A byte is 8 bits. A kilobyte is 1,024 bytes (2^10). A megabyte is 1,048,576 bytes (2^20). A gigabyte is 1,073,741,824 bytes (2^30). Storage manufacturers often use powers of 10 instead (1 GB = 1,000,000,000 bytes), which is why a 1 TB drive shows about 931 GiB in your operating system. The IEC prefixes (kibi, mebi, gibi) were introduced to resolve this ambiguity, but the industry still uses both conventions. Understanding the binary basis of data sizes explains why these numbers appear everywhere in computing. Error detection and correction codes use binary arithmetic extensively. Parity bits add a single bit to a data word to make the total number of 1-bits either even (even parity) or odd (odd parity). Hamming codes use multiple parity bits at positions that are powers of 2 (1, 2, 4, 8, 16) to detect and correct single-bit errors. CRC codes use polynomial division in binary (GF(2) arithmetic, where addition is XOR) to generate checksums. These techniques are fundamental to reliable data storage and transmission. Boolean algebra, the mathematics behind digital logic, operates in binary. AND, OR, NOT, XOR, NAND, and NOR gates take binary inputs and produce binary outputs. Truth tables enumerate all possible input combinations and their outputs. Karnaugh maps and Boolean simplification reduce complex expressions to minimal gate implementations. Every digital circuit, from a simple calculator to a modern CPU, is built from these binary logic gates. Understanding binary is the entry point to understanding how hardware works at the lowest level. Instruction sets and machine code are binary sequences that the CPU executes directly. An x86 instruction like MOV EAX, 5 is encoded as binary bytes. Assembly language provides human-readable mnemonics for these binary instructions. When you compile code in C, Java, or any other language, the compiler ultimately produces binary machine instructions. Viewing compiled code in a hex editor reveals the raw binary (displayed as hex bytes) that the processor runs. Quantum computing introduces a different paradigm with qubits that can exist in superpositions of 0 and 1. Classical binary computing uses definite bits. Quantum computing uses probability amplitudes. However, the output of a quantum computation is measured as classical binary bits. The interface between quantum and classical computing still uses traditional number bases, and quantum algorithms are designed and analyzed using conventional binary mathematics. The WebRecast number base converter accepts input in any of the four bases and outputs the equivalent value in all others. Type a decimal number and see its binary, octal, and hex representations. Paste a hex color code and see its binary form. Enter a binary string from a datasheet and get the decimal value. The conversions happen in real time as you type, making it fast to explore how values relate across bases. Use it alongside your code editor, debugger, or data analysis tools whenever you need to move between number systems quickly and accurately.

Frequently asked questions

What bases are supported?

Binary (2), Octal (8), Decimal (10), and Hexadecimal (16).

Related guides

Related WebRecast sections