Binary Converter Calculator
Decimal to binary, octal, hex.
Formula
Base conversion
Example
255 → 11111111, FF.
Embed this calculator on your site
Add this free calculator to your own website with one line of code. The embedded version is responsive, ad-free, and includes a small attribution link back to CalcNest AI.
<iframe src="https://calcnestai.com/embed/binary-converter-calculator.html" width="100%" height="700" frameborder="0" style="border: 1px solid #e5e5e5; border-radius: 12px; max-width: 720px;" loading="lazy" title="Binary Converter Calculator — Free Tool by CalcNest AI"></iframe>
Understanding the Binary Converter Calculator
A base converter expresses a decimal integer in binary, octal, and hexadecimal. Base is a matter of representation rather than value: forty-two is the same quantity whether written 42, 101010, or 2A, and only the notation changes.
How it actually works
Enter a decimal number. The calculator converts it to base 2, base 8, and base 16. Forty-two becomes 101010 in binary, 52 in octal, and 2A in hexadecimal.
| Hex digit | Binary |
|---|---|
| 0 | 0000 |
| 7 | 0111 |
| A | 1010 |
| F | 1111 |
The deeper context most people miss
Each hexadecimal digit maps to exactly four binary digits, because 16 is 2 to the fourth. That makes conversion between them purely mechanical with no arithmetic, which is why hex is the standard shorthand for binary data rather than a base anyone computes in.
Why computers use binary at all
The reason is physical rather than mathematical. A circuit distinguishing two states, on and off or high and low voltage, is enormously more reliable than one distinguishing ten, because noise and component variation can shift a signal considerably without crossing the single threshold between two states. With ten states the margins shrink tenfold and reliability collapses. Early machines did experiment with other bases, and the Soviet Setun computer used balanced ternary in 1958 with genuine theoretical advantages including more efficient representation, and it did not survive because binary components were simpler and cheaper to manufacture. Once binary was established, everything else followed: logic gates implement Boolean operations directly, arithmetic circuits build from them, and memory stores bits. Octal was widely used in early computing because machines with word sizes divisible by three, including 12, 24, and 36 bit systems, mapped cleanly to it, and it survives in Unix file permissions where three bits of read, write, and execute form one octal digit. Hexadecimal became dominant as byte-oriented architecture with 8-bit bytes took over, since two hex digits express one byte exactly. The persistence of both is a good illustration of how technical conventions outlive the hardware that motivated them.
A worked example: reading 101010 without converting
Binary 101010 is 42 because the digits, read from the right, represent 1, 2, 4, 8, 16, 32, and the set bits are at positions worth 2, 8, and 32. Any positional numeral system works the same way: each digit is multiplied by the base raised to its position, which is why the same procedure converts any base. The practical skills worth having are recognising powers of two on sight, since they appear constantly in computing as memory sizes, addressing limits, and array bounds, and knowing that 2 to the 10 is 1,024, which is where the kilobyte confusion originates. Converting from decimal is done by repeated division by the base, taking remainders in reverse order, or for binary specifically by subtracting the largest fitting power of two repeatedly. Hexadecimal is read in four-bit groups, so 2A splits into 0010 and 1010, giving 101010 directly with a leading zero. Colour codes in web design are hexadecimal, with each pair of digits giving one channel from 0 to 255, which is why a code reading FF then 00 then 00 is pure red and why FF appears so often. MAC addresses, memory dumps, hashes, and character encodings all use hex for the same reason: it compresses binary into something readable without arithmetic.
Deciding where base conversion actually matters
Several practical contexts require it. Debugging memory and network data means reading hex dumps, where knowing that a byte is two hex digits and recognising ASCII ranges makes raw data legible. Bitwise operations require thinking in binary, and they appear in flags, permissions, masks, and low-level optimisation, with bit shifting being equivalent to multiplying or dividing by powers of two. Unix file permissions use octal, where 755 means read, write, and execute for the owner and read and execute for others, and understanding that each digit is three bits makes the notation systematic rather than memorised. Network addressing uses binary directly for subnet masks, where CIDR notation counts leading one bits and the boundaries only make sense in binary. Colour values in graphics and web work are hex. Character encoding involves code points frequently expressed in hex. Hashes and checksums are conventionally hex. Assembly and machine code work is binary and hex throughout. Against that, most application programming rarely requires manual conversion, since languages provide literals in multiple bases and conversion functions, and the skill that matters more is recognising when a value is being displayed in a base other than the one you assumed, which is a recurring source of confusion when a number looks wrong by a factor that turns out to be a base mismatch.
Two's complement and how negative numbers are stored
Representing negative integers in binary required a design decision, and the near-universal answer is two's complement, where the most significant bit indicates sign and negative values are formed by inverting all bits and adding one. The reason it won over the alternatives is that addition and subtraction work identically for signed and unsigned values, so a single adder circuit handles both without special cases, and there is exactly one representation of zero. Sign-and-magnitude and one's complement both produce two zeros and require additional logic. The consequences are visible to programmers. The range is asymmetric, so an 8-bit signed value runs from −128 to 127, and negating the most negative value overflows because its positive counterpart does not exist, which is a genuine edge case that has caused real bugs. Overflow wraps around silently in many languages, so adding one to the maximum value gives the minimum, which has produced famous failures including score counters wrapping in games and, more seriously, the Ariane 5 launch failure in 1996 caused by a conversion overflow. Right shifting a negative number differs between arithmetic and logical shifts, and languages differ in which they provide. The year 2038 problem arises because signed 32-bit second counts overflow then, which is the same class of issue as the year 2000 problem and is being addressed by widening the type.
Variations: other bases, encodings, and notation
Base 64 encodes binary data as printable characters using 64 symbols, which is why it appears in email attachments and data URLs, and it expands data by about a third rather than compressing it, a point frequently misunderstood. Base 32 and base 58 serve similar purposes with different character sets, with base 58 excluding visually ambiguous characters and being used in cryptocurrency addresses for that reason. Balanced ternary uses digits of −1, 0, and 1 and has elegant properties. Base 12 has been advocated for its divisibility. Base 60 survives from Babylonian mathematics in our division of hours and angles. In notation, prefixes distinguish bases in most languages, with 0x for hex, 0b for binary, and a leading 0 or 0o for octal, and the bare leading zero convention has caused bugs where a value like 010 was intended as ten and interpreted as eight. Digit grouping with underscores is supported in several modern languages and improves readability of long binary literals. Endianness determines byte order in multi-byte values and differs between architectures, which matters when reading binary data across systems and is a classic source of subtle bugs in file formats and network protocols.
Working with number bases
Read hexadecimal in four-bit groups, since each hex digit maps to exactly four binary digits and conversion between them needs no arithmetic. Recognise powers of two on sight, since they appear constantly as memory sizes, addressing limits, and shift amounts. Note that 2 to the 10 is 1,024, which is the origin of the kilobyte ambiguity between decimal and binary prefixes. Use language literals with explicit prefixes rather than converting manually, and be careful with a bare leading zero, which means octal in several languages and has caused real bugs. Understand two's complement for signed values, including the asymmetric range where an 8-bit signed value runs from −128 to 127 and negating the minimum overflows. Watch for silent overflow wraparound, which has caused failures ranging from wrapping game scores to the Ariane 5 loss. Read Unix permissions as three octal digits of three bits each, which makes them systematic. Check endianness when reading binary data across systems. And note that base 64 expands data by about a third rather than compressing it.
What people get wrong
- Assuming base 64 compresses data, when it encodes binary as printable characters and expands the size by roughly a third.
- Writing a leading zero before a decimal literal, which several languages interpret as octal, so 010 becomes eight rather than ten.
- Forgetting that signed integer ranges are asymmetric under two's complement, so negating the most negative value overflows because its positive counterpart does not exist.
- Ignoring endianness when reading binary data across systems, where byte order differs between architectures and produces values that are wrong in a non-obvious way.
Where the math comes from
A positional numeral system represents a value as the sum of each digit multiplied by the base raised to its position. Conversion from decimal proceeds by repeated division by the target base, collecting remainders in reverse. Hexadecimal maps to binary in four-bit groups because 16 is 2⁴, and octal in three-bit groups because 8 is 2³.
Questions and answers
Why use hex instead of decimal?
Hex aligns with bytes - two hex digits = one byte. This makes binary data easier to read and write than decimal.
What is the difference between binary and hex?
Binary is base 2 (0,1). Hex is base 16 (0-9, A-F). Both represent the same numbers. Hex is more compact (4 binary digits = 1 hex digit).
How do I convert between bases?
Calculator does it instantly. By hand: divide repeatedly by the target base, collect remainders in reverse order.
Why does 1 KB sometimes equal 1024 bytes?
Computer scientists often use binary prefixes: 1 KiB = 1024 bytes. Marketing usage typically uses 1 KB = 1000. The IEC formalized 'kibi/mebi/gibi' for the binary versions.
What is two's complement?
Standard way of representing signed integers in binary. Most significant bit indicates sign; negative numbers are bitwise inverted plus 1. Allows addition and subtraction with the same hardware.
Why do computers use binary?
For physical reliability rather than mathematical elegance. A circuit distinguishing two voltage states tolerates far more noise and component variation than one distinguishing ten, where the margins between states would be a tenth as wide.
Why is hexadecimal used so much?
Because each hex digit corresponds to exactly four binary digits, making conversion mechanical with no arithmetic. Two hex digits express one byte, which is why memory dumps, colour codes, MAC addresses, and hashes are all conventionally written in hex.
What is octal still used for?
Mainly Unix file permissions, where three bits of read, write, and execute form one octal digit, so 755 is systematic rather than arbitrary. It was widely used in early computing on machines with word sizes divisible by three.
How are negative numbers stored?
In two's complement, formed by inverting all bits and adding one. It won because addition and subtraction work identically for signed and unsigned values using one adder circuit, and because it has exactly one representation of zero.
Why does an 8-bit signed range go to 127 but −128?
Because two's complement has one more negative value than positive, since zero occupies a slot on the positive side. A consequence is that negating the most negative value overflows, as its positive counterpart cannot be represented.
Does base 64 compress data?
No, it expands it by roughly a third. It encodes arbitrary binary as printable characters so data can pass through text-only channels such as email or be embedded in data URLs, which is a transport concern rather than a size one.
What is endianness?
The order in which bytes of a multi-byte value are stored, which differs between architectures. It matters when reading binary data written on a different system, and mismatches produce values wrong in ways that aren't obvious from inspection.
Related calculators
Circle · Pythagorean Theorem · Percentage Change · Scientific Notation · Triangle