How Base Conversion Works
To convert between bases, write the number as powers of the base: 255 is FF in hex (15 × 16 + 15), 11111111 in binary and 377 in octal. Type a number in any base from 2 to 36 above, including negatives, fractions such as 0.1 and whole numbers of any size, to see it in decimal, binary, hex, octal and a custom base, with the steps.
Every digit is worth its value times a power of the base. In hex, FF means 15 × 16 + 15 = 255; in binary, 11111111 means 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. To go the other way, divide by the new base again and again and read the remainders from the last to the first. The converter above does both, exactly, in your browser.
Decimal, Binary, Octal and Hex Reference
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 100 | 1100100 | 144 | 64 |
| 127 | 1111111 | 177 | 7F |
| 128 | 10000000 | 200 | 80 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 1,000 | 1111101000 | 1750 | 3E8 |
| 1,024 | 10000000000 | 2000 | 400 |
| 65,535 | 1111111111111111 | 177777 | FFFF |
| 4,294,967,295 | 11111111111111111111111111111111 | 37777777777 | FFFFFFFF |
One hex digit is exactly 4 bits and one octal digit exactly 3 bits, which is why programmers read binary in hex: 1111 1111 is F F.
Worked Examples
Hex 2F to decimal
2 × 16 + F (15) × 1 = 32 + 15 = 47.
Decimal 0.1 to binary
Multiply the fraction by 2 and keep the whole-number carry each time: 0.2 (0), 0.4 (0), 0.8 (0), 1.6 (1), then 0.6 gives 1.2 (1), 0.4 (0), 0.8 (0), 1.6 (1) and the pattern repeats. So 0.1 = 0.000110011001100... in binary, forever. Computers store a rounded version, which is why 0.1 + 0.2 prints as 0.30000000000000004 in JavaScript. The converter shows the first 32 digits and flags the result as repeating.
Negative numbers: −5 and −129
The plain answer is −101 in binary. Hardware stores it in two's complement: flip the bits of 5 (00000101 to 11111010) and add 1, giving 11111011 = 0xFB in 8 bits. −129 does not fit in 8 bits (the range is −128 to 127), so it needs 16: 1111111101111111 = 0xFF7F. The converter picks the smallest of 8, 16, 32, 64 bits and up.
Numbers past 253
Ordinary JavaScript numbers are exact only up to 9,007,199,254,740,991. Type 9007199254740993 into a converter that uses them and it silently becomes ...992. This converter uses BigInt, so 9,007,199,254,740,993 is exactly 0x20000000000001, and 264 = 18,446,744,073,709,551,616 is exactly 0x10000000000000000.
Common Mistakes
- Prefixes: 0x, 0b and 0o only mark the base. Type 0xFF with base 16 selected, or just FF; the converter accepts both.
- Base 32 is not Base32 encoding: here base 32 counts with 0 to 9 and A to V, so 255 is 7V. RFC 4648 Base32, used in authenticator app secrets, uses A to Z and 2 to 7 and encodes bytes, not numbers.
- Leading zeros in code: in older JavaScript and in C, 010 means octal 8. Write 0o10 for octal and 10 for decimal to avoid surprises.
- Letter case: ff, FF and Ff are the same hex value.
- Two's complement width: 0xFB is −5 only if you read it as a signed 8-bit value; as an unsigned byte it is 251.
Base64, used to encode files and binary data as text, is a different thing from counting in base 64; for that use the Base64 encoder.
Number Base Questions
11111111 in binary: 8 bits, or one byte.101010. Verify: 32+8+2 = 42. This tool shows the exact division steps for any number. The "Step-by-step Conversion" section above walks through each division for the number you enter.#FF5733 is three bytes (R=255, G=87, B=51). Memory addresses like 0x7FFE4000 are easier to read than binary. The prefix 0x indicates hex in most programming languages. 256 bytes = 0x100 in hex = 100000000 in binary.chmod 755 command uses octal: 7 = 111 (read+write+execute), 5 = 101 (read+execute). The three digits represent Owner, Group, and Others permissions. chmod 644 = Owner read+write (110=6), Group read-only (100=4), Others read-only (100=4). chmod 777 gives full permissions to everyone. Octal is also used in some network protocols and escape sequences (\077 in C).00000101. Flip bits: 11111010. Add 1: 11111011 = -5. In an 8-bit signed integer, the range is -128 to +127. The most significant bit (leftmost) is the sign bit: 0 = positive, 1 = negative. Two's complement is elegant because addition and subtraction use the same hardware circuit regardless of sign. 5 + (-5) = 00000101 + 11111011 = 100000000 (the overflow bit is discarded) = 0. This converter accepts negative numbers and, for whole negatives, also shows the two's complement form in the smallest fitting width (8, 16, 32, 64 bits and up).data:image/png;base64,...) is not the same as counting in base 64; it is an encoding scheme. This converter supports mathematical base conversion up to Base 36 (the maximum using standard alphanumeric digits).0xFF = 255 (max unsigned byte, all bits set). 0x00 = 0. 0x80 = 128 (most significant bit set in a byte). 0xDEADBEEF = a classic placeholder/debug value. 0xCAFEBABE = Java class file magic number. 0x7FFFFFFF = 2,147,483,647 (max positive 32-bit signed int). 0xFFFFFFFF = 4,294,967,295 (max unsigned 32-bit int). 0x00000000 = null pointer. #FFFFFF = white in CSS. #000000 = black. #FF0000 = pure red. Memory addresses on 64-bit systems are 16 hex digits long (e.g., 0x00007FFF5FBFF888).#A3B4C5 is three bytes: R=A3, G=B4, B=C5. Convert each byte from hex to decimal: A3 = 10×16+3 = 163. B4 = 11×16+4 = 180. C5 = 12×16+5 = 197. So #A3B4C5 = rgb(163, 180, 197). Short hex colors like #FFF expand to #FFFFFF (each digit is doubled). Use this converter: enter A3 in the input, set base 16, read the decimal result = 163. Repeat for B4 and C5. Alternatively, parseInt("A3", 16) in JavaScript returns 163 directly.&): both bits must be 1. OR (|): either bit is 1. XOR (^): bits are different. NOT (~): flips all bits. Left shift (<<): multiplies by 2 per shift. Right shift (>>): divides by 2 per shift. Common uses: n & 1 checks if n is odd (last bit). n & (n-1) clears the lowest set bit (checks if n is a power of 2 when result is 0). 1 << n computes 2^n efficiently. x | 0x20 converts an uppercase ASCII letter to lowercase (sets bit 5). Bitwise ops are critical in networking (IP masking), cryptography, graphics, and embedded systems.