Skip to main content

Base Converter

Convert numbers between binary, decimal, hexadecimal, and octal instantly. Includes binary padding, two's complement, ASCII output, and step-by-step conversion. Free for programmers, students, and developers.

Last revised Maintained by Pavan Kusunuri · About our editorial standards

Calculator inputs

Conversion Settings

Enter the number you want to convert.

Your results

Hexadecimal (Base 16)
FF
Input: 255 (base 10) → Decimal: 255
Decimal (Base 10)
255
Binary (Base 2)
11111111
Octal (Base 8)
377
Conversion Steps
Input: 255 (base 10) Decimal: 255 (base 10) Binary: 11111111 (base 2) Octal: 377 (base 8) Hex: FF (base 16)
Bit Length
8

Methodology

Formula:
Converting to decimal
Content last updated:
Scheduled re-verification:
October 2027

Calculation type: Exact calculation.

How to Use This Calculator

  1. Enter Input Value

    Type or paste the number you want to convert.

  2. Select Input Base

    Choose the base of your input number (binary, octal, decimal, hex).

  3. Select Output Base

    Choose the base to convert to.

  4. Review Results

    See the converted value in all four bases instantly.

Example: Converting 255 Decimal to Hex

Converting decimal 255 to hexadecimal, binary, and octal.

Example Inputs
Input Value
255
Input Base
Decimal (10)
Output Base
Hexadecimal (16); every base is listed below
Example Results
Decimal (Base 10)
255
Binary (Base 2)
11111111
Octal (Base 8)
377
Hexadecimal (Base 16)
FF
Figures are indicative only and may vary.

Understanding Your Results

  • Decimal (Base 10)
    The standard number system used in everyday life, with digits 0-9.
  • Binary (Base 2)
    The number system used by computers, with digits 0 and 1.
  • Hexadecimal (Base 16)
    A compact representation of binary using digits 0-9 and letters A-F.
  • Octal (Base 8)
    A number system using digits 0-7, historically used in computing.

Key Tips

  • Binary is the foundation of all computing and digital systems.
  • Hexadecimal is commonly used for memory addresses and color codes.
  • Octal is used in Unix/Linux file permissions (chmod).
  • Use binary padding to align numbers to specific bit widths.
  • Two's complement represents negative numbers in binary.

Understanding Number Bases and Conversions

What Is a Number Base?

A number base, also called a radix, determines how many unique digits a numbering system uses before it 'rolls over' to the next position. Decimal is base 10 (digits 0-9), the system we count with daily. Binary is base 2 (0 and 1), used by every computer processor. Octal is base 8 (0-7), and hexadecimal is base 16 (0-9 plus A-F, where A=10 through F=15). The base tells you what each position is worth — for example, in decimal, the number 255 means 2×100 + 5×10 + 5×1, where the multipliers are powers of 10. In binary, 11111111 means 1×128 + 1×64 + … + 1×1, where the multipliers are powers of 2.

How Conversion Between Bases Works

Converting between bases involves repeatedly dividing or multiplying by the target base. To convert decimal 255 to binary, divide by 2 repeatedly: 255 ÷ 2 = 127 remainder 1, 127 ÷ 2 = 63 remainder 1, and so on until you reach 0. Reading the remainders bottom-up gives 11111111. To convert binary to decimal, multiply each digit by its positional power of 2 and sum the results. The same logic applies to any base pair: repeatedly divide by the target base for integer conversions, or multiply fractional parts by the target base for fractional conversions. The calculator shows these steps so you can follow the logic.

Why Hexadecimal Is Essential in Programming

Hexadecimal is the bridge between human-readable notation and raw binary. Each hex digit maps directly to exactly 4 bits: 0=0000, F=1111. This makes hex far more compact than binary while staying directly translatable. A 32-bit memory address like 0xFF00A3C1 is unwieldy in binary (11111111000000001010001111000001) but manageable in hex. Hex is used for color codes (#FF5733), memory addresses in debuggers, machine code representation, Unicode code points, and network MAC addresses. Learning to read hex is one of the most practical skills for any programmer or hardware designer.

Two's Complement — How Computers Store Negative Numbers

Computers don't have a minus sign. Instead, they represent negative integers using two's complement, where the most significant bit indicates sign (0=positive, 1=negative), and the value is the bitwise complement of the positive number plus one. For example, in an 8-bit system, the number -1 is stored as 11111111, not as 10000001. Two's complement simplifies hardware because addition works the same regardless of sign — adding 5 (00000101) and -3 (11111101) in 8-bit yields 2 (00000010) with no special handling. Toggle the two's complement option to see how any number appears in signed binary representation at your chosen bit width.

Binary Padding and Bit Widths

Binary numbers are often displayed at a fixed bit width — 8, 16, 32, or 64 bits — with leading zeros added as padding. This is crucial in contexts like digital logic design, memory addressing, and data protocols where every field must occupy a precise number of bits. Enabling binary padding formats the output to your selected width. For example, decimal 15 becomes 00001111 in 8-bit, 0000000000001111 in 16-bit, and so on. Bit width also interacts with two's complement: in 8-bit, the range is -128 to 127; in 16-bit, it expands to -32,768 to 32,767.

Converting Between Bases Step by Step

To convert decimal 42 to binary, divide repeatedly by 2 and read the remainders bottom-to-top: 42÷2=21 r0, 21÷2=10 r1, 10÷2=5 r0, 5÷2=2 r1, 2÷2=1 r0, 1÷2=0 r1 → 101010. To convert 101010 (binary) back to decimal, multiply each digit by its positional power of 2 and sum: (1×32)+(0×16)+(1×8)+(0×4)+(1×2)+(0×1) = 42. The same repeated-division method converts decimal to any base — divide by 16 instead of 2 for hex, by 8 for octal — and the same positional-power-sum method converts any base back to decimal.

ASCII and Text Encoding

Standard ASCII assigns a decimal value from 0-127 to each character: uppercase and lowercase letters, digits, punctuation, and control codes. Codes 0-31 and 127 are non-printable control characters; 32-126 are printable. Extended ASCII (128-255) adds accented letters and symbols, though modern systems mostly use UTF-8, which is backward-compatible with ASCII for values 0-127 but supports the full range of Unicode characters beyond it. Enabling 'Show ASCII / Text Equivalent' converts a value in the printable 32-126 range to its character; values outside that range are reported as non-printable rather than guessed at.

Limitations of This Calculator

This calculator handles standard integer base conversion for bases 2, 8, 10, and 16 — it does not convert fractional (non-integer) values, and very large numbers may lose precision due to JavaScript's number handling. Two's complement output depends on the selected bit width; choosing a width too small for the entered value will produce a truncated or misleading result. ASCII conversion only covers the standard printable range (32-126); it does not attempt extended ASCII or multi-byte UTF-8 decoding.

Formula & methodology

Formula used

Converting to decimal

value = Σ (digit ᵢ × baseⁱ), counting i from 0 at the rightmost digit

Each digit is worth its face value multiplied by the base raised to its position.

Converting from decimal

repeatedly divide by the target base; the remainders, read bottom to top, are the digits

The standard repeated-division algorithm.

Two's complement

negative value = 2^bits − |value|

How signed integers are represented in a fixed number of bits.

Variable definitions

SymbolMeaningUnit
valueInput value. the number to convert, written in the input basedigits
baseBase. the radix, from 2 (binary) to 36count
bitsBit width. the register size used for padding and two's complementbits

Step-by-step calculation

  1. 1. Enter the value and its base
    Digits must be valid for that base — no 2 in a binary number.
  2. 2. Choose the output base
    Binary padding and two's complement apply to the bit width you set.

Limitations

  • Works on integers. Fractional values in a non-decimal base are not supported.
  • Values are held as JavaScript numbers, so integers beyond 2^53 lose precision.
  • Two's complement output depends entirely on the bit width chosen; the same negative number looks different at 8, 16 and 32 bits.

This page is educational. It applies the formula described above to the figures you enter and shows the arithmetic behind the result. The output is only as good as the inputs and the assumptions listed here, and it is general information rather than advice about your particular situation.

Frequently Asked Questions

How do I convert binary to decimal?

Multiply each binary digit by 2 raised to its position (starting from 0 on the right) and sum the results. For example, binary 1010 = (1×8) + (0×4) + (1×2) + (0×1) = 10. The calculator does this automatically — enter your binary number, set the input base to 2, and the results list it in decimal, octal and hexadecimal as well as the output base you choose.

What is two's complement and when should I use it?

Two's complement is how computers represent signed (negative and positive) integers in binary. The leftmost bit indicates sign, and the value is derived by inverting all bits and adding 1. Toggle 'Show Two's Complement' to see the signed representation of your number at your selected bit width. This is useful for low-level programming, digital logic design, and understanding how integer overflow works.

What is hexadecimal actually used for?

Hexadecimal compactly represents binary data. Each hex digit corresponds to exactly 4 bits. Common uses include: color codes in web design (#FF5733), memory addresses in debugging, Unicode code points (U+0041 for 'A'), MAC addresses (00:1A:2B:3C:4D:5E), and machine code representation. The calculator shows the hex equivalent for any number you enter.

Why does my binary output show leading zeros?

Leading zeros appear when binary padding is enabled and the number doesn't fill the selected bit width. For example, decimal 15 in 8-bit padded binary is 00001111 — the four leading zeros ensure exactly 8 bits are displayed. This is standard in digital systems where every value occupies a fixed number of bits. Disable padding or change the bit width to adjust the output format.

What's the difference between octal and hexadecimal?

Octal (base 8) uses digits 0-7, with each digit representing 3 bits. Hexadecimal (base 16) uses 0-9 and A-F, with each digit representing 4 bits. Octal was popular in early computing when 12, 24, and 36-bit word sizes were common — since 3 divides evenly into those. Today, hexadecimal is far more common because modern architectures use 8/16/32/64-bit sizes where 4-bit nibbles are the natural grouping. Octal persists mainly in Unix file permissions (chmod 755).

Need more help? Contact support or email globalcalqulate@gmail.com. We typically reply within 24–48 hours.