Click to show tips
Try an Example
Pick a scenario to see how the calculator works, then adjust the values
ASCII Letter A
Convert the ASCII code for uppercase A (65) across all bases.
Key values: Decimal 65 · Binary 1000001 · Hex 41
Byte Maximum
The largest value a single byte can hold (255).
Key values: Decimal 255 · Binary 11111111 · Hex FF
Hex Color Code
Convert a common hex color code (deep sky blue) to other bases.
Key values: Hex 00BFFF · Decimal 49151 · Binary nibbles
About the Number Base Converter
A number base converter translates values between different positional numeral systems. In everyday life we use base 10 (decimal), but computers operate in base 2 (binary), and programmers routinely work with base 8 (octal) and base 16 (hexadecimal). This converter handles all four standard bases and any custom base from 2 to 36.
Type a value into any base field and the other representations update instantly. Supports integers of arbitrary size (via BigInt), fractional numbers, negative values in sign-magnitude form, and programming prefixes such as 0b, 0o, and 0x.
How Positional Numeral Systems Work
Every positional system encodes a number as a sequence of digits, where each digit is multiplied by the base raised to the power of its position. The general formula is:
General Formula:
where is the base and is the digit at position .
For example, the decimal number 345 means , which is . The same principle applies to every base: in binary, 1010 means in decimal.
Supported Bases
Binary (Base 2)
Uses digits 0 and 1. Binary is the native language of digital electronics -- each bit represents an on/off transistor state. A group of 8 bits forms a byte (values 0-255), and 4 bits form a nibble (values 0-15, which maps exactly to one hex digit).
Octal (Base 8)
Uses digits 0-7. Each octal digit corresponds to exactly 3 binary bits. Octal is most commonly seen in Unix file permissions: chmod 755 means owner=rwx (7), group=r-x (5), others=r-x (5).
Decimal (Base 10)
The familiar base used in everyday mathematics. Uses digits 0-9. Thought to have originated from counting on ten fingers.
Hexadecimal (Base 16)
Uses digits 0-9 and letters A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Each hex digit maps to exactly 4 binary bits, making hex a compact and convenient representation for binary data. Hex is used for CSS color codes (#FF5733), memory addresses, MAC addresses, and cryptographic hashes.
Custom Bases (2-36)
Any integer base from 2 to 36 is supported. Bases above 10 extend the digit alphabet with uppercase letters: A=10, B=11, ..., Z=35. For example, base 36 uses the full set 0-9 and A-Z.
Conversion Algorithms
Base N to Decimal (Integer Part)
Multiply each digit by its positional weight and sum:
Decimal to Base N (Integer Part) -- Repeated Division
Repeatedly divide the decimal number by the target base, recording remainders:
- Divide the number by the target base.
- Record the remainder -- this is the next digit (least significant first).
- Replace the number with the quotient.
- Repeat until the quotient is zero.
- Read the digits in reverse order (bottom to top).
Example: 42 decimal to binary
Reading remainders bottom-to-top:
Fractional Part -- Repeated Multiplication
For the fractional portion, multiply by the target base and take the integer part as each digit:
- Multiply the fraction by the target base.
- The integer part of the product is the next fractional digit.
- Replace the fraction with the remaining fractional part.
- Repeat until the fraction is zero or you reach the desired precision.
Example: 0.6875 decimal to binary
Result:
Non-terminating fractions: Some decimal fractions cannot be represented exactly in another base. For example, in decimal produces a repeating pattern in binary: . The converter truncates such expansions to the configured precision and indicates when truncation has occurred.
Nibble Grouping (Binary-Hex Shortcut)
Since , each hexadecimal digit corresponds to exactly 4 binary bits (a nibble). This means you can convert between binary and hex by simply grouping bits into sets of four, starting from the right:
Similarly, octal uses 3-bit groups: each octal digit maps to exactly 3 binary bits.
Real-World Examples
1. CSS Color Codes -- Web Development
CSS colors are specified in hexadecimal. The color #FF5733 breaks down as: Red = FF (255), Green = 57 (87), Blue = 33 (51). In binary, the red channel is -- all 8 bits are set, meaning maximum intensity. Understanding hex-to-decimal conversion is essential for web developers who need to manipulate colors programmatically.
2. Unix File Permissions -- System Administration
The command chmod 755 sets file permissions using octal notation. Each octal digit represents 3 permission bits: read (4), write (2), execute (1). So = rwx (all permissions), and = r-x (read and execute only). In binary, , and in decimal it equals 493.
3. Network Subnet Masks -- Networking
The subnet mask 255.255.255.0 in binary is -- 24 bits set to 1 followed by 8 bits of 0. This is written as /24 in CIDR notation. Converting between decimal and binary helps network engineers understand which bits belong to the network address versus the host address.
4. Memory Addresses -- Debugging
When debugging software, memory addresses are displayed in hex. A typical 64-bit address like 0x7FFEE3B4A8C0 is far more readable than its binary equivalent of 48 bits. The classic test value 0xDEADBEEF equals 3,735,928,559 in decimal and has 32 bits in binary.
5. Embedded Systems -- Register Configuration
Microcontroller registers are configured by setting individual bits. A control register value of 0xA5 in hex = in binary shows exactly which bits are set. Bit 7 (128), bit 5 (32), bit 2 (4), and bit 0 (1) are enabled, for a decimal value of 165.
Historical Context
Base-10 counting likely arose from humans having ten fingers. The ancient Babylonians used base 60 (sexagesimal), which is why we have 60 seconds in a minute and 360 degrees in a circle. The Mayans used base 20 (vigesimal).
Binary was formalized by Gottfried Wilhelm Leibniz in 1703, though it was already used in ancient Chinese mathematics (the I Ching). Binary became practical with Claude Shannon's 1937 insight that Boolean algebra could model electrical switching circuits, forming the theoretical foundation of digital computing.
Hexadecimal gained popularity in the 1960s with the IBM System/360, which used 8-bit bytes. Hex provided a compact two-character representation for each byte, compared to eight characters in binary or three in decimal (with values up to 255).
Common Misconceptions
"Hex letters A-F represent text characters"
In hexadecimal, A through F are numeric digits, not letters. A represents the value ten, B represents eleven, and so on through F representing fifteen. They are used because we need 16 unique single-character symbols and our standard digit set (0-9) only provides 10.
"0.1 decimal = 0.1 binary"
This is false. The fraction (one-tenth) cannot be represented exactly in binary. It becomes the repeating pattern . This is why floating-point arithmetic in computers sometimes produces surprising results like .
"Larger base numbers are bigger than smaller base numbers"
The string "10" means different values in different bases: , , . The base determines the weight of each position.
Frequently Asked Questions
Why do computers use binary instead of decimal?
Electronic circuits have two stable states: high voltage (on) and low voltage (off). Binary maps perfectly to these two states, making it the most reliable and efficient representation for digital hardware. Building circuits with 10 distinct voltage levels (for decimal) would be far more complex and error-prone.
What is the relationship between hex and binary?
Since , each hex digit encodes exactly 4 binary bits. This makes conversion between hex and binary trivially simple: group binary digits into sets of 4 and translate each group to its hex equivalent. For example, .
Can this converter handle very large numbers?
Yes. The integer portion uses JavaScript BigInt internally, which supports integers of arbitrary magnitude without precision loss. The fractional portion uses standard floating-point arithmetic, which may introduce rounding for very long fractional expansions.
What does "non-terminating fraction" mean?
Some fractions that terminate in one base repeat infinitely in another. For example, is a non-terminating fraction in binary (). The converter truncates such expansions at the configured precision and marks the result as truncated.
What are the prefixes 0b, 0o, and 0x?
These are programming conventions to indicate the base of a number literal: 0b for binary (e.g., 0b1010), 0o for octal (e.g., 0o755), and 0x for hexadecimal (e.g., 0xFF). The converter strips these prefixes automatically for convenience.
Why is base 36 the maximum?
Base 36 uses all 10 digits (0-9) plus all 26 letters of the Latin alphabet (A-Z), exhausting the standard single-character symbols. Bases higher than 36 would require multi-character digit symbols, which would make input and display ambiguous.
References
- Knuth, D.E. The Art of Computer Programming, Vol. 2, §4.1. Addison-Wesley.
- Stallings, W. Computer Organization and Architecture, 10th ed. Pearson.
- Wikipedia. "Positional notation." https://en.wikipedia.org/wiki/Positional_notation
- Wikipedia. "Two's complement." https://en.wikipedia.org/wiki/Two%27s_complement
- Wikipedia. "Sexagesimal." https://en.wikipedia.org/wiki/Sexagesimal
Disclaimer
This calculator is provided for educational and informational purposes. While it uses BigInt for arbitrary-precision integer arithmetic, fractional conversions may exhibit minor rounding due to floating-point limitations. For mission-critical applications requiring exact fractional arithmetic (e.g., financial or cryptographic systems), use specialized arbitrary-precision libraries. The converter does not implement two's complement, IEEE 754 floating-point encoding, or other hardware-specific binary representations.
Specialized Calculators
Choose from 6 specialized versions of this calculator, each optimized for specific use cases and calculation methods.
Conversion
6 CalculatorsRelated Calculators
6 CalculatorsMore Math calculators