From low-level systems programming in Rust and C++ to debugging binary network protocols, memory dumps, bitwise permission flags, and cryptographic hashes, number base conversion is an essential skill for modern software engineers.
While high-level application languages abstract away underlying bit patterns, computers fundamentally process and store data in binary voltages ($0$ and $1$). Representing these raw bits in human-readable formats—such as Hexadecimal (Base 16), Octal (Base 8), and Decimal (Base 10)—requires an understanding of positional numeral systems and hardware representation rules.
In this guide, we explore positional radices, direct nibble-to-hex mappings, two's complement signed integers, and IEEE 754 floating-point encoding.
1. Positional Numeral Systems & Radix Arithmetic
In any positional numeral system with base (or radix) $b$, an integer $N$ is expressed as a polynomial sequence of digits $d_i$:
$$N = \sum_{i=0}^{n-1} d_i \cdot b^i = d_{n-1} b^{n-1} + \dots + d_1 b^1 + d_0 b^0$$
Where each digit satisfies $0 \le d_i < b$.
Common Computing Bases
| Base Name | Radix ($b$) | Digits Used | Primary Computing Use Case |
|---|---|---|---|
| Binary | $2$ | 0, 1 |
Machine instructions, logic gates, bitmasks |
| Octal | $8$ | 0–7 |
Unix file permissions (chmod 755), legacy PDP architectures |
| Decimal | $10$ | 0–9 |
Human user interfaces, financial calculations |
| Hexadecimal | $16$ | 0–9, A–F |
Memory addresses, byte dumps, color codes (#0284c7), hash digests |
| Base 36 | $36$ | 0–9, A–Z |
URL shorteners, compact human-readable alphanumeric IDs |
You can convert numbers across any of these numeral systems instantly using our Number Base Converter.
2. Direct Binary to Hexadecimal Mapping (Nibble Grouping)
Because $16 = 2^4$, exactly 4 binary digits (one nibble) map to 1 hexadecimal digit. This eliminates the need to calculate intermediate decimal numbers when converting between binary and hex.
Binary: 1 1 0 1 0 1 0 0 1 0 1 1 1 1 1 1
Nibbles: [ 1101 ] [ 0100 ] [ 1011 ] [ 1111 ]
Decimal: 13 4 11 15
Hexadecimal: D 4 B F
Result: 0xD4BF
Common 4-bit Nibble Lookup Table
| Hex | Binary | Decimal | Hex | Binary | Decimal |
|---|---|---|---|---|---|
0 |
0000 |
0 | 8 |
1000 |
8 |
1 |
0001 |
1 | 9 |
1001 |
9 |
2 |
0010 |
2 | A |
1010 |
10 |
3 |
0011 |
3 | B |
1011 |
11 |
4 |
0100 |
4 | C |
1100 |
12 |
5 |
0101 |
5 | D |
1101 |
13 |
6 |
0110 |
6 | E |
1110 |
14 |
7 |
0111 |
7 | F |
1111 |
15 |
3. Two's Complement for Signed Integers
Computers store signed negative integers in Two's Complement representation. This allows CPU ALUs (Arithmetic Logic Units) to perform subtraction using identical addition circuits without requiring separate sign-magnitude comparison logic.
Calculating Two's Complement for an $N$-bit Value
To find the negative representation $-X$ of a positive value $X$:
- Write $X$ in binary padded to $N$ bits.
- Invert every bit ($0 \to 1$, $1 \to 0$), producing the One's Complement ($\sim X$).
- Add $1$ to the least significant bit: $-X = \sim X + 1$.
Example: Find -42 in 8-bit Two's Complement
1. Positive 42: 00101010
2. Invert bits (NOT): 11010101
3. Add 1: + 00000001
---------------------------------
Result (-42): 11010110 (0xD6)
Signed Integer Limits by Bit Width
- 8-bit (int8 / signed char): $-128$ to $+127$
- 16-bit (int16 / short): $-32,768$ to $+32,767$
- 32-bit (int32 / int): $-2,147,483,648$ to $+2,147,483,647$
- 64-bit (int64 / long long): $-9,223,372,036,854,775,808$ to $+9,223,372,036,854,775,807$
Test signed integer boundaries and interactive bit-flipping with our Number Base Converter.
4. IEEE 754 Floating-Point Decomposition
Real fractional numbers (e.g. 3.14159 or -0.00125) are standardized under IEEE 754. Single-precision (binary32, float in C/Rust) and double-precision (binary64, double in C/Rust or number in JavaScript) partition binary words into three fields:
$$\text{Value} = (-1)^{\text{sign}} \times (1 + \text{mantissa}) \times 2^{\text{exponent} - \text{bias}}$$
IEEE 754 Single Precision (32-bit):
[ Sign (1 bit) ] [ Exponent (8 bits) ] [ Mantissa / Significand (23 bits) ]
Bit 31 Bits 30-23 Bits 22-0
IEEE 754 Double Precision (64-bit):
[ Sign (1 bit) ] [ Exponent (11 bits) ] [ Mantissa / Significand (52 bits) ]
Bit 63 Bits 62-52 Bits 51-0
Exponent Biases
- Single Precision (32-bit): Bias $= 127$ ($2^{8-1} - 1$)
- Double Precision (64-bit): Bias $= 1023$ ($2^{11-1} - 1$)
5. Endianness: Big-Endian vs. Little-Endian
When multi-byte integers are serialized to memory or disk:
- Big-Endian (Network Byte Order): Most significant byte (MSB) is written at the lowest memory address. Standard in Internet protocols (CIDR & Subnetting, TCP/IP).
- Little-Endian: Least significant byte (LSB) is written at the lowest memory address. Standard in x86-64 and modern ARM CPUs.
32-bit Integer: 0x12345678
Address Offset: 0x00 0x01 0x02 0x03
Big-Endian: 0x12 0x34 0x56 0x78 (MSB first)
Little-Endian: 0x78 0x56 0x34 0x12 (LSB first)
Summary & Developer Tooling
Understanding number bases accelerates performance diagnostics, binary serialization debugging, and low-level system design.
For instant conversion with BigInt precision, two's complement calculations, interactive bit grids, and IEEE 754 float inspection, use our browser-based Number Base Converter. Combine it with Base64 Encode/Decode for binary data transfer and Hash Generator for cryptographic digests.