Number Base Converter

Converts any non-negative integer between binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16) simultaneously. Shows grouped binary output and a step-by-step breakdown. Useful for programmers, students, and electronics engineers working across different numbering systems.

S. Siddiqui

Edited by

S. SiddiquiFounder & Editor-in-Chief
Sources:NISTSI BrochureBIPMUpdated Jul 2026
0b
0o
0x
Quick Answer: Decimal 255 is 11111111 in binary, 377 in octal, and FF in hex. Enter any number above and all four bases update instantly.

What Is a Number Base Converter?

A number base converter translates the same integer value between different positional numeral systems. Every number you can write in decimal (the everyday base-10 system) has an exact equivalent in binary (base 2), octal (base 8), and hexadecimal (base 16). The digit changes; the quantity does not.

Computers store and process data using only two electrical states: on and off. Binary maps perfectly to those states, making it the native language of every processor, memory chip, and network card ever built. Hexadecimal compresses long binary strings into a shorter, human-readable form, which is why you see it in colour codes, memory addresses, and cryptographic hashes. Octal was widely used in early Unix systems and still appears in Linux file-permission notation.

Understanding all four systems side by side, rather than learning isolated conversion formulas, is the fastest path to fluency. According to the NIST Digital Computer Arithmetic guidelines, positional notation in bases 2, 8, and 16 are the three most important supplementary systems for engineering and computer science education. The Wikipedia article on positional notation provides a thorough mathematical treatment of how any base-n system works.

How to Use the Number Base Converter

  1. Type or paste a number into any of the four input boxes (binary, octal, decimal, or hex).
  2. The converter validates your input instantly: binary fields reject digits above 1, octal fields reject 8 and 9, and hex fields reject non-hex characters.
  3. All other three fields update in real time to show the equivalent value.
  4. For binary output, a grouped format (e.g. 1111 1111) appears below the field for easier reading.
  5. The step-by-step panel at the bottom shows the conversion path from decimal to each base.
  6. Use the Copy button next to any field to copy that representation to your clipboard.
  7. Click Reset to clear all fields and start fresh.

Binary vs Octal vs Decimal vs Hex: Key Differences

BaseDigits UsedPrefixPrimary Use CaseExample (255)
Binary (2)0, 10bCPU registers, boolean logic, bitmasking11111111
Octal (8)0 to 70oUnix file permissions, legacy systems377
Decimal (10)0 to 9noneHuman-facing numbers, mathematics255
Hex (16)0 to 9, A to F0xMemory addresses, colours, hashes, debuggingFF

When to Use the Number Base Converter

The Computer Science Student Translating Between Systems

A first-year computing student is working through a binary arithmetic assignment. The question asks them to add 0b10110111 and 0b01101001 and verify the result in decimal. They type each binary number into the converter, confirm the decimal equivalents (183 and 105), add them (288), then type 288 into the decimal field to get 0b100100000 and verify their hand-worked binary sum. The side-by-side view makes carry-bit errors visible immediately.

The Web Developer Debugging a Colour Code

A front-end developer receives a design spec that lists an accent colour as 0xFF6B35 (a hex literal used in an SVG filter). They need to pass it to a CSS custom property in rgb() format. They paste FF6B35 into the hex field: red = FF = 255, green = 6B = 107, blue = 35 = 53. They write rgb(255, 107, 53) without touching a separate tool.

The Embedded Systems Engineer Reading a Datasheet

An electronics engineer is configuring a microcontroller register. The datasheet shows the status register value as 0x9A. The engineer needs to know which individual bits are set. They enter 9A into the hex field and read the binary output: 1001 1010. Bits 7, 4, 3, and 1 are set, immediately identifying the interrupt flag, overflow flag, carry flag, and half-carry flag without manual binary expansion.

The System Administrator Checking File Permissions

A Linux sysadmin sees a file with permission mode 0o755 in a script and needs to confirm what it means in practice. They enter 755 into the octal field and see decimal 493 and binary 111 101 101. Reading the binary in three-bit groups: 111 = rwx (owner), 101 = r-x (group), 101 = r-x (world). The permission structure becomes instantly legible.

Common Mistakes When Converting Number Bases

Confusing the base with the digit count is a frequent error. The fact that hexadecimal uses 16 digits does not mean a two-digit hex number represents a two-digit decimal. FF in hex is 255 in decimal, a three-digit value.

Forgetting zero-padding in binary causes misreads in communications protocols. A byte is always 8 bits. The decimal value 7 is 00000111 as a byte, not just 111. When interpreting register values or network packets, the bit position matters as much as the bit value.

Treating uppercase and lowercase hex as different values is a common mistake when cross-referencing manual calculations. ff, FF, and Ff are all 255. This converter normalises to uppercase to match the most common programming convention (C, Python's hex(), JavaScript's toString(16).toUpperCase()).

Mixing octal and decimal in copy-pasted code is surprisingly easy. In many programming languages, a leading zero on an integer literal signals octal: 010 is 8 in C, Java, and JavaScript's non-strict mode, not 10. Always verify whether a literal with a leading zero is intentionally octal before using it.

Step-by-Step: How Each Base Conversion Works

Understanding the mechanics of base conversion helps you spot errors and do rough mental checks without a tool. The core algorithm in every direction involves repeatedly dividing or expanding by the target base.

Decimal to Binary

Divide the decimal number by 2 and note the remainder. Repeat with the quotient until you reach 0. Read the remainders from bottom to top. For decimal 45: 45 / 2 = 22 remainder 1, 22 / 2 = 11 remainder 0, 11 / 2 = 5 remainder 1, 5 / 2 = 2 remainder 1, 2 / 2 = 1 remainder 0, 1 / 2 = 0 remainder 1. Reading upward: 101101. Binary 101101 = decimal 45.

Decimal to Hexadecimal

Divide by 16 and note the remainder. Remainders above 9 become letters: 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F. For decimal 255: 255 / 16 = 15 remainder 15 (F), 15 / 16 = 0 remainder 15 (F). Reading upward: FF. Hex FF = decimal 255.

Binary to Hexadecimal (Shortcut)

Group the binary digits into sets of four from the right, padding with leading zeros if needed. Convert each group directly to one hex digit. Binary 11111010: groups are 1111 and 1010. 1111 = 15 = F. 1010 = 10 = A. Result: FA. This shortcut works because 2^4 = 16, meaning four binary digits map perfectly to one hex digit without a conversion through decimal.

Octal to Binary

Each octal digit maps directly to exactly three binary digits. Octal 7 = binary 111. Octal 4 = binary 100. Octal 755 = 111 101 101. This is why Unix file permissions in octal translate directly to the three-group binary representation of read-write-execute flags.

Real-World Reference Values

DecimalBinaryOctalHexWhy It Matters
0000Null / false / off
1111True / on / set
81000108One byte shifted left by 3
16100002010Hex digit boundary
127011111111777FSigned 8-bit maximum
1281000000020080Sign bit in signed bytes
25511111111377FFMaximum unsigned byte
256100000000400100First 9-bit value
655351111111111111111177777FFFFMaximum unsigned 16-bit

Number Base Conversion in Programming Languages

Every major programming language has built-in support for working with multiple number bases, and understanding the notation prevents subtle bugs that arise when numeric literals are misread across systems.

In Python, you write binary literals as 0b1010 (decimal 10), octal as 0o17 (decimal 15), and hexadecimal as 0x1A (decimal 26). The built-in functions bin(), oct(), and hex() convert any integer to its string representation in that base. The reverse, converting a string in a known base to a Python integer, uses int('1010', 2) for binary, int('17', 8) for octal, and int('1A', 16) for hexadecimal.

JavaScript handles base conversion through parseInt('FF', 16) for parsing and (255).toString(16) for output. A critical JavaScript pitfall: parseInt with no radix argument interprets strings starting with 0x as hex, but older engines sometimes treated strings starting with 0 as octal, a behaviour now removed in strict mode. Always pass an explicit radix.

In C and C++, integer literals starting with 0x are hexadecimal and literals starting with 0 (but not 0x) are octal. Writing int x = 010; sets x to 8, not 10. This has caused real production bugs in systems where configuration values were copied from documentation that used leading zeros as formatting.

Binary Number Systems in Hardware and Electronics

Digital electronics operates entirely in binary at the gate level. Every logic gate (AND, OR, NOT, XOR, NAND, NOR) takes binary inputs and produces a binary output. The patterns of 0s and 1s passing through millions of transistors determine whether a processor adds two numbers, stores a byte to memory, or sends a packet over a network interface.

Microcontroller datasheets routinely specify register values in hexadecimal because it is compact and maps directly to binary bit fields. A 16-bit control register described as 0x0281 contains binary 0000 0010 1000 0001. Reading this in grouped binary, an engineer immediately sees that bits 9, 7, and 0 are set, corresponding to specific hardware features. Reconstructing this without a base converter requires mental arithmetic that is error-prone under time pressure.

Network engineers use hexadecimal when reading MAC addresses (00:1A:2B:3C:4D:5E) and IPv6 addresses (2001:0db8:85a3::8a2e:0370:7334). Each colon-separated group in an IPv6 address is a 16-bit hexadecimal value. Troubleshooting routing issues sometimes requires converting specific groups to binary to verify subnet masks and interface identifiers at the bit level.

Networking protocols also rely heavily on hexadecimal notation. Ethernet MAC addresses are expressed as six pairs of hex digits separated by colons or hyphens. Colour values in HTML and CSS have been written as six-digit hex codes since the earliest web standards. Memory debugging tools display raw byte values in hex because two hex digits represent exactly one byte, making it far easier to spot patterns and boundaries in memory dumps than a long decimal number would allow.

For anyone beginning to learn programming or digital electronics, the effort invested in understanding all four number bases pays dividends immediately. Most debugging scenarios in embedded systems and network programming reduce, at some level, to understanding what a sequence of bits or bytes actually represents. The converter above is a starting point; over time the most common conversions, particularly between hex and binary, become mental shortcuts that experienced engineers apply automatically.

Frequently Asked Questions

Last reviewed: July 26, 2026
Founder's Real-World Experience
S. Siddiqui

S. Siddiqui

Founder & Editor-in-Chief, YourToolsBase

How I used a number base converter to debug a microcontroller register setting that was silently corrupting sensor data

In March 2026 I was helping a client configure a custom IoT sensor board for a cold-chain monitoring project. The microcontroller was an STM32, and the board was intermittently dropping temperature readings without triggering any error flag. The firmware developer had been chasing the bug for two days.

I looked at the sensor's I2C configuration register. The datasheet specified the register should be set to 0x17 to enable 12-bit resolution and continuous conversion mode. The developer had set it to decimal 17 in their initialisation code, assuming hex and decimal were interchangeable for small numbers. They are not. Hex 0x17 is decimal 23, not decimal 17.

I opened the number base converter, typed 17 into the hex field, and the decimal output showed 23. Then I typed 17 into the decimal field and the hex output showed 11. The developer had written decimal 17, which is hex 0x11, which set only one of the three required configuration bits. The sensor was running in 9-bit low-power mode instead of 12-bit continuous mode, silently truncating resolution and dropping readings when the conversion cycle did not complete within the polling interval.

Correcting the register value to decimal 23 (hex 0x17) resolved the dropout issue immediately. Two days of debugging came down to a single number base confusion that a 30-second converter check would have caught at the start.

Hex 0x17 confirmed as decimal 23, not decimal 17Misconfigured register identified without hardware oscilloscopeTwo-day debugging session resolved in under 5 minutes
Also used alongside: Binary to Text Converter

Frequently Asked Questions

What is the largest number this converter handles?
The converter handles integers up to 2^53 - 1 (9,007,199,254,740,991), which is the safe integer limit in JavaScript. For most practical use in programming and electronics, this covers every register value and memory address you will encounter.
Why does hexadecimal use letters A through F?
Hexadecimal needs 16 symbols for digits 0 through 15. The digits 0 to 9 cover the first ten values. Letters A (10), B (11), C (12), D (13), E (14), and F (15) extend the set. This convention was standardised in the 1960s and is now universal across programming languages, datasheets, and hardware documentation.
How does binary relate to bytes and bits?
One bit is a single binary digit (0 or 1). Eight bits form one byte, which can represent decimal values 0 through 255 (binary 00000000 to 11111111). Two hex digits also represent one byte (00 to FF), which is why hex is such a compact notation for byte-level data like colours and memory addresses.
What does the 0b, 0o, and 0x prefix mean?
These are programming prefixes that tell a compiler or interpreter which base a number literal uses. 0b signals binary (e.g. 0b1010), 0o signals octal (e.g. 0o12), and 0x signals hexadecimal (e.g. 0xA). In plain mathematics and most datasheets, numbers are written without a prefix and the base is stated separately.
How do I convert a negative number between bases?
This converter handles non-negative integers only. Negative numbers in computing use representations such as two's complement, which requires a fixed bit width. To convert a negative value, first determine the two's complement binary representation at your target bit width (8, 16, 32, or 64 bits), then convert that binary string.
Is octal still used in modern computing?
Yes, though mainly in Unix and Linux contexts. File permission notation uses octal exclusively: chmod 755 sets owner read-write-execute and group and world read-execute. Octal also appears in some network protocols and assembly programming for older architectures.
Why do computer scientists prefer hex over binary for large values?
A single hex digit represents exactly four binary digits (a nibble). This means an 8-bit byte needs two hex digits instead of eight binary digits, and a 32-bit value needs eight hex digits instead of 32 binary digits. Hex is a lossless shorthand for binary that is far less likely to cause reading errors.
Can I use this converter for floating-point numbers?
No. This converter handles integers only. Floating-point values (such as 3.14) are stored in IEEE 754 format, which involves a sign bit, an exponent, and a mantissa. Converting a decimal fraction to its binary or hex IEEE 754 representation requires a different, more specialised tool.
What is a nibble in binary?
A nibble is four bits, or half a byte. It can represent decimal values 0 to 15, which maps exactly to one hexadecimal digit (0 to F). The term is used in networking (for representing subnet masks compactly) and in hardware documentation where register fields are described in four-bit chunks.
How do I check my manual binary-to-decimal conversion?
Enter your binary number into the binary field. The decimal field will show the correct value instantly. To verify manually: multiply each bit by 2 raised to its position (starting from 0 on the right), then sum the results. For 1011: (1x8) + (0x4) + (1x2) + (1x1) = 11.

Rate This Tool

Was this tool helpful?

Be the first to rate this tool

About the Author

S. Siddiqui

S. Siddiqui

Founder & Editor-in-Chief

LinkedIn Profile

S. Siddiqui is the founder and editor-in-chief of YourToolsBase, overseeing all content, tool accuracy, and editorial standards.

View full profile

Authoritative Sources

Formulas and data in this tool are based on guidelines from the above sources.