Math

Binary Calculator

Convert between binary, decimal, hexadecimal, and octal. Perform binary arithmetic with step-by-step solutions and multiple bit-length displays.

Quick Answer

Binary uses base-2 (0 and 1). To convert decimal to binary, repeatedly divide by 2 and read remainders bottom-up. For example, 42 in binary is 101010 (32+8+2). Hexadecimal uses base-16 (0-9, A-F) and octal uses base-8 (0-7).

Base Converter

Enter a number in any base and see it converted to all other bases instantly.

Conversions

BinaryBase 2
0b101010
DecimalBase 10
42
HexadecimalBase 16
0x2A
OctalBase 8
0o52

Binary Representations

8-bit8 bits
0010 1010
16-bit16 bits
0000 0000 0010 1010
32-bit32 bits
0000 0000 0000 0000 0000 0000 0010 1010

Bit Position Values

Position543210
Power222³2²2¹2
Value32168421
Bit101010

32 + 8 + 2 = 42

About This Tool

The Binary Calculator converts numbers between binary (base-2), decimal (base-10), hexadecimal (base-16), and octal (base-8) number systems. It also performs binary arithmetic operations with step-by-step explanations. This tool is essential for computer science students, programmers, and anyone working with low-level data representation.

Understanding Number Bases

A number base (or radix) defines how many unique digits are used. Decimal uses 10 digits (0-9), binary uses 2 (0 and 1), octal uses 8 (0-7), and hexadecimal uses 16 (0-9 and A-F). Each position in a number represents a power of the base. In decimal, 42 means 4×10¹ + 2×10 = 42. In binary, 101010 means 1×32 + 0×16 + 1×8 + 0×4 + 1×2 + 0×1 = 42.

Why Binary Matters in Computing

Computers use binary because digital circuits have two states: on (1) and off (0). Every piece of data in a computer, from text to images to programs, is ultimately represented as sequences of 0s and 1s. Understanding binary is fundamental to computer science, networking (IP addresses), file permissions (Unix chmod), and color codes. A single binary digit is called a bit, and 8 bits make a byte.

Hexadecimal in Practice

Hexadecimal is widely used in computing because each hex digit represents exactly 4 binary bits (a nibble). This makes it a compact way to express binary values. Memory addresses, color codes (#FF5733), MAC addresses, and many debugging tools use hex notation. Converting between hex and binary is straightforward: each hex digit maps to a 4-bit binary pattern (A = 1010, F = 1111, etc.).

Octal Usage

Octal was historically important in early computing when systems used word sizes that were multiples of 3 bits. Today, it is primarily used in Unix/Linux file permissions (chmod 755), where each octal digit represents 3 permission bits (read, write, execute). While less common than hexadecimal in modern computing, understanding octal is still valuable for systems administration and computer science education.

Frequently Asked Questions

How do I convert decimal to binary by hand?
Divide the decimal number by 2 repeatedly, writing down the remainder each time. Continue until the quotient is 0. Then read the remainders from bottom to top. For example, 13 / 2 = 6 remainder 1, 6 / 2 = 3 remainder 0, 3 / 2 = 1 remainder 1, 1 / 2 = 0 remainder 1. Reading bottom-up: 1101.
What's the difference between 8-bit, 16-bit, and 32-bit?
The bit width determines the range of numbers that can be represented. An 8-bit number can represent values from 0 to 255 (or -128 to 127 signed). 16-bit covers 0 to 65,535. 32-bit covers 0 to about 4.29 billion. The tool shows your number padded to each bit width, with leading zeros to fill the full width.
Why is hexadecimal used for colors?
Web colors use three 8-bit values (0-255 each) for red, green, and blue. In hex, each color channel is exactly 2 digits (00-FF), making the full color code exactly 6 characters (like #FF5733). This is more compact than writing three decimal numbers (255, 87, 51) and directly maps to the underlying binary representation used by displays.
How does binary addition work?
Binary addition follows the same rules as decimal, but with only two digits. 0+0=0, 0+1=1, 1+0=1, 1+1=10 (0 carry 1). When both digits and a carry are 1: 1+1+1=11 (1 carry 1). Work right to left, just like decimal addition, carrying over when the sum exceeds 1.
Can negative numbers be represented in binary?
Yes, using several methods. The most common is two's complement, where the leftmost bit indicates sign (0=positive, 1=negative). To negate a number, flip all bits and add 1. For example, in 8-bit two's complement, -1 is 11111111 and -128 is 10000000. This calculator handles positive integers and shows the result's sign separately.

Was this tool helpful?