CalcFolio

Binary Converter

Use this binary converter to switch whole numbers between binary, decimal, hexadecimal, octal or any base from 2 to 36. Pick a bit width to see the two's-complement pattern of a negative number, or change mode to turn text into binary bytes and binary back into text. Numbers of up to 1,000 digits are converted exactly, without rounding.

Updated

Convert

Whole number; spaces, _ and 0b/0o/0x prefixes are accepted

2 = binary, 8 = octal, 10 = decimal, 16 = hex

Adds the two's-complement pattern

For a raw bit pattern such as 10000000 or FFFE

Encoded as UTF-8

Groups of up to 8 bits separated by spaces, or a continuous run

How to use the converter

Number mode

  1. Number: type a whole number. Spaces and underscores are ignored, a leading minus sign is allowed, and you can paste prefixes such as 0b, 0o or 0x in bases 2, 8 and 16. Letters A–Z stand for the digits 10 to 35.
  2. From base / To base: any base from 2 to 36. The result is also always shown in binary, octal, decimal and hex, and the table lists every base from 2 to 36.
  3. Bit width (optional): 8, 16, 32 or 64 bits adds the two's-complement pattern in binary and hex, with its signed and unsigned readings. Tick Read input as a two's-complement pattern if what you typed is a raw bit pattern rather than a signed number.

Text modes

Text → binary shows the UTF-8 bytes of your text in binary, hex and decimal, with one table row per character. Binary → text decodes groups of up to 8 bits separated by spaces, commas or new lines, or one continuous run whose length is a multiple of 8.

How the conversion works

In base b, each digit is multiplied by a power of b according to its position. In binary, 10011100 means 128 + 16 + 8 + 4 = 156. The converter reads your digits into an exact integer, then writes that integer in the target base, so long numbers keep every digit. Negative numbers are written with a minus sign, for example −42 = -101010.

Two's complement. With a width of n bits, a negative number is stored as 2ⁿ plus the number. The calculator accepts −2ⁿ⁻¹ up to 2ⁿ − 1, which covers both the signed and the unsigned reading (0 to 2ⁿ − 1 when the input is read as a raw pattern). Bits needed counts the bits of the magnitude, without the sign.

UTF-8. Text is encoded as defined in RFC 3629:

Code pointsBytes
U+0000 to U+007F (ASCII)1
U+0080 to U+07FF2
U+0800 to U+FFFF3
U+10000 to U+10FFFF4

Worked examples

1. Decimal to binary and hex

Decimal 156 is 10011100 in binary, 234 in octal and 9C in hex. Decimal 255 is 11111111, or FF, the largest value of one byte.

2. Negative numbers in 8 bits

Number8-bit patternHexUnsigned reading
−11111 1111FF255
−421101 0110D6214
−1281000 000080128

Going the other way, the pattern 1100 1000 typed as decimal 200 reads as −56 when signed. In 16 bits, −12345 is CFC7.

3. Text to binary

"Hi!" becomes 01001000 01101001 00100001, which is 48 69 21 in hex and 72 105 33 in decimal: three characters, three bytes. The string é€😀 is three characters but 9 bytes: é is C3 A9, € is E2 82 AC and the emoji is F0 9F 98 80.

Reading the results

The plain result is the mathematical value of your number in the new base. The two's-complement outputs show how that value is stored in a fixed number of bits, which is what you see in a debugger or a memory dump. If decoding binary fails, check that every group has at most 8 bits and that the bytes form valid UTF-8.

Frequently asked questions

How do I convert decimal to binary by hand?

Divide by 2 repeatedly and write down the remainders. For 156: 78 r0, 39 r0, 19 r1, 9 r1, 4 r1, 2 r0, 1 r0, 0 r1. Read the remainders from the last to the first: 10011100. To check, add the powers of 2 where there is a 1: 128 + 16 + 8 + 4 = 156.

Why do programmers use hexadecimal?

One hex digit stands for exactly 4 bits, so a byte is always two hex digits. Binary 1011 0110 becomes B6 by translating each group of four on its own. That makes hex a compact way to read and write bit patterns.

What is two's complement, and why is −1 all ones?

Two's complement is the usual way computers store signed integers. To negate a number, invert every bit and add one. Starting from 1 = 0000 0001, inverting gives 1111 1110, and adding one gives 1111 1111. So −1 is all ones in any width: FF in 8 bits, FFFFFFFF in 32 bits.

What range fits in 8 bits?

Signed, 8 bits hold −128 to 127; unsigned, 0 to 255. The converter accepts −128 to 255 at 8 bits and shows both readings. A value such as 300 gives an error because it does not fit.

Why does an emoji take 4 bytes in binary?

UTF-8 uses 1 byte for ASCII characters and up to 4 bytes for others. Code points above U+FFFF, where most emoji sit, need 4 bytes. The 😀 emoji is U+1F600, encoded as 11110000 10011111 10011000 10000000.

Can I convert fractions or floating-point numbers?

No. The converter handles whole numbers only, so 3.5 returns an error. Floating-point formats such as IEEE 754, one's complement, byte order and encodings other than UTF-8 are not covered.

Sources

  1. RFC 3629 — UTF-8, a transformation format of ISO 10646 (IETF, 2003)
  2. Unicode Consortium — FAQ: UTF-8, UTF-16, UTF-32 & BOM
  3. Thomas Finley, Cornell University — Two's complement

This converter is a learning and reference tool. Check results against your language's or hardware's documentation before relying on them in production code.