OtherCalculators

Binary Converter

Convert numbers between binary, decimal, hexadecimal, octal and any base from 2 to 36. Type in any field and every other base updates instantly.

Conversions are exact for numbers of any length, including 64-bit values, and the step-by-step panel shows the working a teacher expects to see.

Last updated: Β· Reviewed by Shakeel Alvi, OtherCalculators

Calculator mode

Type in any field

The other fields update as you type. Spaces, underscores and the prefixes 0b, 0o and 0x are fine, and a leading minus sign makes the number negative.

Group binary digits
Hex letters

255₁₀ in binary

1111 1111

Hexadecimal
FF
Octal
377

Bits
8
Bytes
1
Fits in
8-bit unsigned

Step-by-step working

Which working to show

Divide by 2 and write down the remainder. Repeat on the quotient until it reaches 0, then read the remainders from the bottom up.

Repeated division of 255 by 2
DivisionQuotientRemainder
255 Γ· 21271
127 Γ· 2631
63 Γ· 2311
31 Γ· 2151
15 Γ· 271
7 Γ· 231
3 Γ· 211
1 Γ· 201

Remainders read from the last row to the first:25510 = 111111112

Exact at any size

Whole numbers are worked digit by digit, so 64-bit values and beyond never round off after 15 or 16 digits. Floating-point mode prints the exact value the bits store.

Runs in your browser

What you enter is worked out on this page and is not sent anywhere. Copy the address to share a conversion.

Binary ↔ DecimalHex & OctalAny Base 2–3664-bit ExactStep-by-StepShareable Links

Quick answer

To convert binary to decimal, add the place values of the 1 bits: 101101 is 32 + 8 + 4 + 1 = 45. To convert decimal to binary, divide by 2 repeatedly and read the remainders from the bottom up. Each hex digit stands for four bits, so 101101 is 2D in hexadecimal and 55 in octal.
Guide

How this binary converter works

The converter holds one number and shows it in five ways. Type in the binary, decimal, hexadecimal or octal field, or pick any base from 2 to 36 for the custom field, and the other four update on every keystroke. Spaces, underscores and the code prefixes 0b, 0o and 0x are accepted, and a character that is not a digit in that base is highlighted instead of being silently dropped.

Below the result, the bit count, byte count and the smallest standard integer width that holds the number are shown. The working panel explains the conversion both ways. For a single direction with a full explanation, see binary to decimal or decimal to binary.

How the maths works

The base conversion formulas

Value = dβ‚™ Γ— bⁿ + … + d₁ Γ— bΒΉ + dβ‚€ Γ— b⁰
Binary place values: 1, 2, 4, 8, 16, 32, 64, 128 …
Decimal β†’ base b: divide by b, keep the remainder, repeat
1 hex digit = 4 bits; 1 octal digit = 3 bits

Example: 2D in hexadecimal is 2 Γ— 16 + 13 Γ— 1 = 45, and 45 in binary is 101101. Grouping 101101 into fours from the right gives 0010 1101, which reads back as 2 and D.

Worked example

Worked examples

Example 1 β€” binary to decimal and hex

Binary:
11010110
  1. Place values of the 1 bits: 128 + 64 + 16 + 4 + 2
  2. Add them: 214
  3. Group in fours: 1101 0110 β†’ D 6

Answer: 214 decimal = D6 hex

Example 2 β€” a 64-bit value

Hexadecimal:
FFFFFFFFFFFFFFFF
  1. 16 hex digits Γ— 4 bits: 64 ones in binary
  2. Largest 64-bit value: 2⁢⁴ βˆ’ 1

Decimal: 18,446,744,073,709,551,615

Ordinary floating-point arithmetic rounds this to 18,446,744,073,709,552,000. Integer arithmetic keeps every digit.

Reference data

0 to 15 in binary, octal and hexadecimal

The decimal numbers 0 to 15 written in binary, octal and hexadecimal
DecimalBinaryOctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
Source: OtherCalculators β€” computed with the converter's own integer engine β€” binary padded to four bits, so each row is exactly one hex digit
Reference data

Largest unsigned value by bit width

The largest unsigned value, 2 to the power n minus 1, for common integer widths
WidthLargest value (decimal)Hexadecimal
8 bits255FF
16 bits65,535FFFF
32 bits4,294,967,295FFFFFFFF
53 bits (JavaScript safe integer)9,007,199,254,740,9911FFFFFFFFFFFFF
64 bits18,446,744,073,709,551,615FFFFFFFFFFFFFFFF
Source: MDN Web Docs β€” Number.MAX_SAFE_INTEGER β€” values computed as 2ⁿ βˆ’ 1; the 53-bit row is Number.MAX_SAFE_INTEGER, past which ordinary JavaScript numbers start to round

Key facts

  • Each binary place value is double the one to its right, so the bits of 101101 are worth 32, 16, 8, 4, 2 and 1, and the number equals 32 + 8 + 4 + 1 = 45.
  • One hexadecimal digit always holds exactly four bits and one octal digit three, because 16 = 2⁴ and 8 = 2Β³; that is why 101101 converts to 2D by grouping alone.
  • An n-bit unsigned integer holds 0 to 2ⁿ βˆ’ 1, so 8 bits reach 255 and 64 bits reach 18,446,744,073,709,551,615.
  • Ordinary JavaScript numbers are exact only up to 9,007,199,254,740,991 (2⁡³ βˆ’ 1), so a converter built on them rounds most 64-bit values.
Guide

Which base to use, and when

Binary

How hardware stores everything. Use it to read individual bits, flags and masks.

Hexadecimal

Compact binary: two hex digits make one byte. Used for memory addresses, colours such as #FF6600 and byte dumps.

Octal

Three bits per digit. It survives mainly in Unix file permissions, where 755 means rwxr-xr-x.

Exam questions

England's GCSE computer science content includes binary and hexadecimal and converting between them and decimal (source: DfE subject content).

Tips

Common conversion mistakes

  • Grouping from the left. Split bits into fours or threes from the right, and pad the leftmost group with zeros.
  • Reading remainders top-down. In repeated division the first remainder is the rightmost bit, not the leftmost.
  • Starting place values at 2. The rightmost bit is worth 2⁰ = 1, not 2.
  • Trusting floating point. Past 2⁡³ a spreadsheet or calculator may round the last digits; check large values with an exact tool.
FAQ

Frequently Asked Questions

How do you convert binary to decimal?

Multiply each bit by its place value and add the results. Place values are powers of 2, starting at 1 on the right and doubling to the left: 1, 2, 4, 8, 16 and so on. For 101101, that is 32 + 8 + 4 + 1 = 45.

How do you convert decimal to binary?

Divide the number by 2 and write down the remainder, then divide the quotient by 2 again, and repeat until the quotient is 0. Reading the remainders from the last one to the first gives the binary number. 45 gives remainders 1, 0, 1, 1, 0, 1, so 45 is 101101.

How do you convert binary to hexadecimal?

Split the binary number into groups of four bits from the right, padding the leftmost group with zeros, then replace each group with one hex digit. 0010 1101 becomes 2 and D, so 101101 is 2D. This works because 16 is 2 to the power 4, so one hex digit always holds exactly four bits.

Why do other converters give wrong answers for large numbers?

Many converters use ordinary JavaScript numbers, which hold whole numbers exactly only up to 9,007,199,254,740,991 (2^53 βˆ’ 1). Past that, the last digits are rounded. This converter uses arbitrary-precision BigInt arithmetic, so 64-bit values such as 18,446,744,073,709,551,615 and much larger numbers convert exactly.

What do the prefixes 0b, 0o and 0x mean?

They mark the base of a number written in code: 0b for binary, 0o for octal and 0x for hexadecimal, so 0b101101, 0o55 and 0x2D are all 45. You can paste a number with its prefix into the matching field and it is read correctly.

How are negative numbers converted?

Type a minus sign in front of the number. The converter keeps the sign, so βˆ’45 is βˆ’101101 in binary, which is the mathematical meaning of a negative binary number. Computers usually store negatives as a fixed-width two's complement bit pattern instead, which is a different representation of the same value.

Keep going

Notes & Assumptions

  • Whole numbers are converted exactly with arbitrary-precision integers, up to 4,096 characters of input.
  • Negative numbers keep a minus sign. Fixed-width two's complement bit patterns are a different representation and are not produced here.
  • Step-by-step working is shown for numbers up to 64 bits; the conversion itself is exact at any length.

This tool is for education and general calculation. Check results that feed into production code or hardware against your platform's own documentation.