Number Systems Guide: Bases, Powers, Roots, and Complex Numbers
A practical guide to number systems: positional bases and conversion, binary and hex arithmetic, exponent and root rules, logarithms, modular arithmetic, and complex numbers.

A number is an abstract quantity; a numeral is the notation we use to write it down. The distinction sounds academic until you try to explain to a computer what "three hundred forty-five" means. Machines do not store quantities — they store symbols, and the rules that give those symbols meaning are called a number system.
This guide covers the number systems that appear most often in practice: positional bases (binary, octal, hexadecimal, decimal), the operations built on repeated multiplication (powers and roots), the operation that reverses them (logarithms), the arithmetic of remainders (modular arithmetic), and the extension of the real line into the complex plane.
Every digital device you use depends on at least four of the topics in this guide:
- Base conversion decides how a value typed as
255becomes0xFFin a stylesheet,11111111in memory, and0377in an octal permission field. - Powers of two set the size of every data type: 8-bit bytes, 32-bit integers, 64-bit addresses.
- Logarithms turn multiplication into addition, which is why slide rules worked and why search algorithms can be logarithmic rather than linear.
- Modular arithmetic is the mathematics behind checksums, hash tables, clock arithmetic, and the public-key encryption that secures every HTTPS connection.
- Complex numbers are the natural language of alternating current, signal processing, and quantum mechanics.
The unifying idea is that notation is a choice and the underlying quantity is not. Once you see the pattern behind positional notation, base 16 stops being exotic and becomes the same idea as base 10 with a different digit set.
[khan-cs]Positional Notation and Bases
In a positional system, the position of a digit determines its weight. A number written in base expands as:
The decimal number 345 is therefore:
Binary uses two digits (0 and 1) and powers of two:
To convert a decimal integer into base , divide repeatedly by and read the remainders from last to first. For 156 in base 2: 156, 78, 39, 19, 9, 4, 2, 1 produce remainders 0, 0, 1, 1, 1, 0, 0, 1 — reversed, that is .
The binary calculator performs both directions at once and also converts to and from octal and hexadecimal, which is the quickest way to check a hand conversion.
Binary Arithmetic
Binary arithmetic follows the same column rules as decimal, with two digits instead of ten. Addition carries when a column reaches 2:
That is 11 plus 6 equals 17. Multiplication is repeated shift-and-add, which is exactly how hardware multipliers work:
11 times 6 equals 66, and 66 in binary is 64 plus 2.
Negative integers are usually stored in two's complement: flip every bit and add one. In an 8-bit register, minus 5 is the bit pattern of 251, which is why signed and unsigned integers can overflow in surprising ways.
Hexadecimal and Octal
Hexadecimal is base 16 and needs sixteen digits, so it borrows A through F for 10 through 15. Its popularity is not aesthetic: one hex digit encodes exactly four bits, so a byte is always two hex digits. The value 255 is and also — one line of text instead of eight.
Octal is base 8 and packs three bits per digit, which is why it survives in Unix file permissions such as 0755.
The hex calculator handles hex arithmetic and converts between hex, decimal, binary, and octal, which makes it useful when you are reading memory dumps, color codes, or permission masks.
Powers and Exponents
An exponent records repeated multiplication:
Five rules cover almost every manipulation you will need:
Fractional exponents are roots in disguise, which is the bridge to the next section:
The exponent calculator accepts positive, negative, zero, and fractional exponents and switches to exponential notation when the result gets too large to display in full.
Roots and Radicals
The -th root asks which number, multiplied by itself times, produces the radicand:
Roots behave like exponents, because they are exponents:
Two asymmetries matter in practice. Square roots of negative numbers have no real solution, which forces the complex numbers described below. Cube roots, by contrast, are defined for negatives: because .
The root calculator extracts square, cube, and any n-th root with adjustable precision, including negative radicands for odd roots. The cube calculator specialises in the cube case: it computes cubes and cube roots and tells you whether the input is a perfect cube such as 27 or 3375.
Logarithms
A logarithm answers the question "what exponent do I need?". It is the inverse of exponentiation:
Three bases dominate practice: base 10 (common log), base (natural log), and base 2 (binary log, the currency of computer science). The rules mirror the exponent laws:
That last identity — change of base — is why a calculator with only a natural log button can still compute a base-2 log. The log calculator works in any base and shows the product, quotient, and power rules applied to your numbers.
Modular Arithmetic
The modulo operation returns the remainder of an integer division:
Two conventions coexist. Truncated division keeps the sign of the dividend, so minus 7 mod 3 gives minus 1. Floored division keeps the sign of the divisor, so minus 7 mod 3 gives 2. Programming languages disagree about which one % implements, which is a classic source of off-by-one bugs when working with negative values.
Congruence notation compresses the same idea: means both numbers leave the same remainder. A clock is the everyday example — 10 o'clock plus 5 hours is 3, not 15.
The modulo calculator uses floored modular arithmetic for values up to 999,999 and shows the remainder directly, which is the convention most number-theory work assumes.
Complex Numbers
The square root of a negative number has no place on the real line, so mathematicians extended the line into a plane by defining:
A complex number has a real and an imaginary part:
Arithmetic works by treating as a symbol and replacing with minus 1 wherever it appears:
Two derived quantities describe the geometry. The modulus is the distance from the origin, and the argument is the angle from the positive real axis:
Together they give the polar form, which turns multiplication into a rotation:
De Moivre's theorem follows immediately: raising to a power multiplies the angle by that power.
The complex number calculator performs all four operations and reports the modulus, argument, conjugate, and polar form alongside the result.
[needham]Example 1: Decimal to Binary
Problem: Write 156 in binary.
Solution: Subtract the largest powers of two that fit: 128 fits, leaving 28; 16 fits, leaving 12; 8 fits, leaving 4; 4 fits, leaving 0. The powers 64, 32, and 2 are unused.
Check by expansion: 128 plus 16 plus 8 plus 4 equals 156.
Example 2: Hexadecimal to Decimal
Problem: Convert to decimal.
Solution: Expand each digit against its power of sixteen, remembering that B is 11, E is 14, and F is 15.
Example 3: Negative and Fractional Exponents
Problem: Evaluate and .
Solution: A negative exponent is a reciprocal, not a negative result:
A fractional exponent is a root first, then a power:
Example 4: Cube Roots and Perfect Cubes
Problem: Find and determine whether 3375 is a perfect cube.
Solution: Factor 3375 by extracting cubes: 3375 equals 27 times 125, and both factors are perfect cubes.
Because the root is an integer, 3375 is a perfect cube. A non-integer root would mean the number is not one.
Example 5: Logarithms in Different Bases
Problem: Evaluate and .
Solution: Ask what exponent produces the argument:
With only a natural log available, change of base gives the same answer: .
Example 6: Modular Arithmetic
Problem: Compute and .
Solution: The first is direct: 5 times 3 is 15, and 17 minus 15 leaves 2.
The second matters because modular exponentiation is the core operation in public-key cryptography: you never need the full power, only its remainder.
Example 7: Complex Multiplication and Polar Form
Problem: Multiply by , then express the first factor in polar form.
Solution: Expand as you would two binomials and use :
For , the modulus is 5 and the argument is about 53.13 degrees:
So . In this form, multiplying by another complex number multiplies the moduli and adds the angles — a rotation plus a scale.
[mathworld-complex]Programming: Bitmasks and Colors
A bitmask is a binary number used as a set of switches. The flag 0b0100 tests bit 2, and the operation value & 0b0100 returns non-zero only when that bit is set. Web colors use the same idea in hex: #1E90FF is three bytes, one per channel, and each pair of hex digits is exactly one byte.
Cryptography: Modular Exponentiation
RSA and Diffie-Hellman both live in modular arithmetic. Encryption raises a message to a power modulo a large number, and decryption reverses it using the structure of the multiplicative group. The security rests on the difficulty of factoring the modulus, which is why number theory from the previous guide and modular arithmetic from this one are two halves of the same story.
Engineering: Impedance and Phasors
Alternating current analysis uses complex numbers because a sinusoid has an amplitude and a phase, and a complex number carries both. Impedance is complex, so Ohm's law becomes with complex quantities, and series impedances add like vectors. The modulus gives the magnitude ratio; the argument gives the phase shift.
Audio: Decibels
A decibel is a logarithm: a gain in dB is ten times the base-10 log of a power ratio. Because logs turn multiplication into addition, cascaded amplifier stages can be summed in dB instead of multiplied as ratios — which is why audio engineers think in addition, not multiplication.
Computing: Big Numbers and Precision
Standard floating point has 53 bits of mantissa, roughly 15 to 17 significant decimal digits. Factorials, combinatorics, and cryptographic keys blow past that immediately: 100 factorial has 158 digits. The big number calculator performs arithmetic with adjustable precision and handles factorials, powers, GCD, and LCM beyond ordinary limits, which is what you need when a result must be exact rather than rounded.
[knuth-taocp2]The Same Values in Four Bases
| 5 | 101 | 5 | 5 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 255 | 11111111 | 377 | FF |
| 1024 | 10000000000 | 2000 | 400 |
Each extra hexadecimal digit adds four bits of range, so the number of representable values grows exponentially with the width of the field.
Exponent, Root, and Logarithm as Inverses
| Exponent | What is the result of repeated multiplication? | 2 to the 10 | 1024 |
| Root | What number, repeated, gives this result? | 10th root of 1024 | 2 |
| Logarithm | What exponent produces this result? | log base 2 of 1024 | 10 |
| Modulo | What remainder is left over? | 1024 mod 7 | 2 |
| Complex modulus | How far is the point from the origin? | 3 + 4i | 5 |
The first three are three views of a single equation, : solve for the result, the base, or the exponent. The logarithm grows so slowly that it compresses enormous ranges into small numbers.
-
Reading binary as decimal. The string
10means ten in base 10 and two in base 2. Always state the base, or use a prefix such as0bor0x, when the context is ambiguous. -
Treating a negative exponent as a negative result. is one eighth, not minus eight. The minus sign inverts the value; it does not change its sign.
-
Assuming the root of a square is always positive. , not . The square root function returns the principal (non-negative) root, so it discards the sign.
-
Forgetting the base of a logarithm. only in base 10. In base 2 it is about 6.64, and in base it is about 4.61. Calculator buttons hide the base, which is exactly why the confusion survives.
-
Mixing floored and truncated modulo. In floored arithmetic, minus 7 mod 3 equals 2; in truncated arithmetic it equals minus 1. Both conventions are in use, so a negative dividend is where bugs appear.
-
Losing the imaginary unit in multiplication. When expanding complex products, every must become minus 1. Dropping that substitution turns a real contribution into an imaginary one and silently changes the answer.
-
Trusting floating point for exact arithmetic. is not exactly 0.3 in binary floating point, because one tenth has no finite binary expansion — the same reason one third has no finite decimal expansion.
- ❓ Why do computers use binary instead of decimal?
- ✅ Because a physical switch has two stable states, on and off. Building circuits that reliably distinguish ten voltage levels is far harder and more error-prone than distinguishing two. Binary also maps cleanly onto Boolean logic, which is what logic gates implement.
- ❓ Why is hexadecimal used if computers work in binary?
- ✅ Hexadecimal is a compact human-readable shorthand for binary. Each hex digit maps to exactly four bits, so a byte is always two hex digits. Reading 0xFF is far less error-prone than counting eight ones and zeros.
- ❓ What is the difference between a root and a logarithm?
- ✅ Both invert exponentiation, but they solve for different unknowns. A root solves b to the y equals x for the base b. A logarithm solves the same equation for the exponent y. Exponentiation solves it for the result x.
- ❓ Can you take the square root of a negative number?
- ✅ Not within the real numbers. Extending the number system with the imaginary unit i, where i squared equals minus 1, makes every negative number have two complex square roots. Odd roots such as the cube root do have real answers for negative inputs.
- ❓ Why does log base 2 matter in computer science?
- ✅ Because binary search and balanced trees halve the problem at each step, so the number of steps is the base-2 logarithm of the input size. An algorithm that takes about 20 steps on a million items is logarithmic, and that is why large datasets remain searchable.
- ❓ What is modular arithmetic used for?
- ✅ Checksums, hash tables, clock arithmetic, cyclic scheduling, and public-key cryptography. Any time a quantity wraps around at a fixed boundary, modular arithmetic is the correct model. It is also the operation behind the last digit of a product or power.
- ❓ Why does minus 7 mod 3 give two different answers?
- ✅ Because there are two conventions. Floored division rounds toward negative infinity and returns 2; truncated division rounds toward zero and returns minus 1. Both satisfy the division identity, differing only in how the remainder is normalised.
- ❓ What does the modulus of a complex number mean?
- ✅ It is the distance from the origin in the complex plane, computed as the square root of a squared plus b squared. For 3 plus 4i the modulus is 5. It is the complex analogue of absolute value, and it multiplies when you multiply complex numbers.
- ❓ What is polar form good for?
- ✅ It turns multiplication into rotation and scaling. In polar form, multiplying two complex numbers multiplies their moduli and adds their arguments, which is why complex numbers describe rotations, oscillations, and alternating current so naturally.
- ❓ When do I need arbitrary-precision arithmetic?
- ✅ When a result must be exact and larger than about 15 significant digits: factorials, binomial coefficients, cryptographic keys, and financial totals. Standard floating point rounds, so exactness requires a big-number library or calculator.
- Argument: The angle of a complex number measured from the positive real axis.
- Base: The number of distinct digits a positional system uses; also the number raised to a power in a logarithm.
- Binary: Base 2, using the digits 0 and 1.
- Bit: A single binary digit.
- Complex number: A number of the form a plus bi, where i squared equals minus 1.
- Conjugate: For a plus bi, the value a minus bi; their product is a squared plus b squared.
- Exponent: The power to which a base is raised.
- Floored modulo: A remainder convention that returns a value with the sign of the divisor.
- Hexadecimal: Base 16, using 0 through 9 and A through F.
- Logarithm: The exponent that produces a given value in a given base.
- Modulus: The remainder in modular arithmetic, or the distance from the origin for a complex number.
- Nibble: Four bits, equivalent to one hexadecimal digit.
- Octal: Base 8, using the digits 0 through 7.
- Polar form: Writing a complex number as modulus times the cosine-plus-i-sine of its argument.
- Positional notation: A numeral system in which a digit's value depends on its position.
- Radicand: The number under a root symbol.
- Two's complement: The standard binary encoding of signed integers.
References
- [1]Knuth, Donald E. (1997). The Art of Computer Programming, Volume 2: Seminumerical Algorithms (3rd ed.). Addison-Wesley.Buy on Amazon
- [2]Cormen, Thomas H., Leiserson, Charles E., Rivest, Ronald L., and Stein, Clifford. (2022). Introduction to Algorithms (4th ed.). MIT Press.Buy on Amazon
- [3]Needham, Tristan. (1997). Visual Complex Analysis. Oxford University Press.Buy on Amazon
- [4]OpenStax. Algebra and Trigonometry 2e (free textbook).
- [5]Weisstein, Eric W. "Complex Number." From MathWorld - A Wolfram Web Resource (free reference).
- [6]Khan Academy. Computers and the Internet: digital information (free).
UnByte — Independent Software Engineering
All reference data cites its sources — Editorial policy
