Nemofy
Skip to main content

Calculators & Number Systems

Pick a calculator below, type or click a sample preset, and get instant step-by-step results.

Number Systems & Computer Arithmetic Reference

Complete Guide to Number Base Conversion, Two's Complement, and Bitwise Logic

Digital computers store all data—integers, characters, memory addresses, and machine instructions—as sequences of binary digits (bits). Mastering positional number systems, signed two's complement representation, and bitwise Boolean algebra is fundamental to computer organization, embedded systems, and cryptography.

Positional Number Systems: Binary (Base 2), Octal (Base 8), Decimal (Base 10) & Hex (Base 16)

In a positional numeral system with radix (base) b, a sequence of digits d_{n-1} ... d_1 d_0 represents the value sum(d_i * b^i) for i = 0 to n-1. While humans naturally compute in Decimal (base 10), digital hardware operates on Binary (base 2) voltage levels (0 and 1).

Hexadecimal (base 16, using digits 0–9 and A–F) serves as a compact human-readable shorthand for binary because exactly 4 binary bits (a nibble) map to 1 hexadecimal digit (2^4 = 16). Similarly, 3 binary bits map to 1 Octal digit (2^3 = 8).

Worked Example: Converting 219 (Decimal) to Binary and Hexadecimal
Decimal Value: 219
Powers of 2:   128 + 64 + 0 + 16 + 8 + 0 + 2 + 1 = 219
Binary (8-bit): 1101_1011₂
Upper Nibble:   1101₂ = 13₁₀ = D₁₆
Lower Nibble:   1011₂ = 11₁₀ = B₁₆
Hexadecimal:    0xDB
  • Group binary digits in blocks of 4 from right to left to convert instantly to Hexadecimal.
  • Group binary digits in blocks of 3 from right to left to convert to Octal.
  • Our Base Converter uses exact BigInt math so 64-bit registers never lose precision.

Signed Integers & Two's Complement Representation

Processors represent negative integers using Two's Complement encoding because it allows a single hardware adder circuit to perform both addition and subtraction without separate sign-bit logic. In an N-bit two's complement system, the Most Significant Bit (MSB) has a negative weight of -2^(N-1), while all other bits have positive weights.

To negate any binary number in two's complement: (1) write its positive N-bit binary representation, (2) invert every bit (One's Complement: 0 becomes 1 and 1 becomes 0), and (3) add 1 to the Least Significant Bit, discarding any carry out of the N-bit width.

Worked Example: Encoding -42 in 8-Bit Two's Complement
Step 1 (Positive Magnitude +42):  0010_1010
Step 2 (Invert Bits / 1's Comp):  1101_0101
Step 3 (Add 1 to LSB):            1101_0101 + 1 = 1101_0110 (0xD6)
Verification: -128 + 64 + 16 + 4 + 2 = -42

Bitwise Boolean Operations & Bit Shifts

Bitwise operators act on individual bit positions in parallel. AND (&) is used to mask or clear bits; OR (|) is used to set bits; XOR (^) toggles bits and detects differences; NOT (~) inverts all bits.

Left shifting (x << k) multiplies an integer by 2^k by shifting bits toward the MSB and filling zeros on the right. Logical right shifting (x >>> k) fills zeros on the MSB, whereas Arithmetic right shifting (x >> k) preserves the sign bit (MSB) for signed two's complement division.

Two's Complement Integer Ranges by Bit Width

Bit Width (N)Unsigned RangeSigned Two's Complement RangeHexadecimal Mask
8-bit (int8_t)0 to 255-128 to +1270xFF
16-bit (int16_t)0 to 65,535-32,768 to +32,7670xFFFF
32-bit (int32_t)0 to 4,294,967,295-2,147,483,648 to +2,147,483,6470xFFFFFFFF
64-bit (int64_t)0 to 2^64 - 1-2^63 to +2^63 - 10xFFFFFFFFFFFFFFFF

Frequently Asked Questions

Reviewed by Nemofy EngineeringAsk a Question →
Why is the negative range in two's complement asymmetric by 1?
Zero (0000...0) has a0 in the sign bit, consuming one of the 2^(N-1) non-negative bit patterns. As a result, an 8-bit signed integer spans -128 (1000_0000) to +127 (0111_1111).
How do I detect signed arithmetic overflow in binary addition?
Signed overflow occurs if and only if adding two positive numbers yields a negative result (MSB = 1), or adding two negative numbers yields a positive result (MSB = 0). Equivalently, the carry into the sign bit differs from the carry out of the sign bit.
Does the Scientific Calculator support both Degrees and Radians?
Yes. You can toggle between RAD (Radians) and DEG (Degrees) at any time for trigonometric functions (sin, cos, tan, asin, acos, atan).