In low-level software engineering, embedded systems, networking protocols, and cryptography, data is rarely stored in the human decimal system. Computers operate fundamentally on voltage levels represented as binary switches (0 and 1). Understanding the mathematical relationships between Binary (Base 2), Octal (Base 8), Decimal (Base 10), and Hexadecimal (Base 16) is a prerequisite for understanding memory layouts, CPU registers, and network packet structures.
A positional numeral system represents any real number as an ordered sequence of digits multiplied by ascending powers of a radix base $b$:
$$\text{Value} = \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$$
Because powers of 2 align perfectly with grouping boundaries:
chmod 755 = 111 101 101).0xFF = 255).In digital circuitry, hardware addition and subtraction units are unified using Two's Complement representation. For an $N$-bit integer system:
$$\text{Negate}(X) = (\sim X) + 1$$
For example, in an 8-bit signed integer space: $+5 = 0000\,0101_2$. Inverting the bits yields $1111\,1010_2$. Adding 1 yields $1111\,1011_2 = -5_{10}$.
| Operation | Operator | Logic Equation | Common Systems Applications |
|---|---|---|---|
| Bitwise AND | & |
1 if both bits are 1 | Masking bits, clearing specific flags (x & ~0x04), subnet masking. |
| Bitwise OR | | |
1 if either bit is 1 | Setting flags or combining options (O_RDWR | O_CREAT). |
| Bitwise XOR | ^ |
1 if bits are different | Toggling bits, parity checks, one-time pads, cryptographic ciphers. |
| Bitwise NOT | ~ |
Inverts 0 to 1 and 1 to 0 | Creating bitwise inverse masks. |
| Left Shift | << |
Shifts bits left, fills with 0 | Rapid multiplication by powers of 2 ($x \times 2^k$), constructing bitmasks (1 << n). |
| Arithmetic Right Shift | >> |
Shifts bits right, preserves sign bit | Division of signed numbers by powers of 2. |
| Logical Right Shift | >>> |
Shifts bits right, fills with 0 | Unsigned division and bit extraction. |
Standard JavaScript numbers are IEEE 754 double-precision 64-bit floating point numbers. When performing standard bitwise operations (such as a | b or a << 2), JavaScript implicitly casts operands to signed 32-bit big-endian integers via the ECMAScript ToInt32 abstract operation. This causes values greater than $2^{31}-1$ to wrap to negative numbers.
To avoid this precision truncation, our converter leverages the browser-native BigInt engine, allowing accurate calculations across 64-bit, 128-bit, 256-bit, and arbitrary bit boundaries without numeric degradation.
>> is an arithmetic (sign-propagating) right shift: if the top bit is 1, it copies 1s into the left side, preserving negative numbers. The triple shift >>> is a logical (zero-fill) right shift: it always inserts 0s from the left, treating the input as an unsigned integer.bool isSet = (value & (1 << n)) != 0; where $n$ is the 0-indexed bit position.