% (Percent Sign) is ASCII code point 37 (0x25), Unicode U+0025, and a printable punctuation character. It expresses a ratio out of one hundred — 50% means half — and always follows the number it modifies, no space, in most English usage. In C-family languages, % is the modulo operator, returning the remainder after integer division: 7 % 3 yields 1. Python extends this to strings, where "Hello %s" % name is the old-school formatting syntax that refuses to die. But the character's most pervasive programming role is in percent-encoding, the scheme that makes URLs safe for transmission: every byte outside the unreserved set becomes a % followed by two hex digits, so a space turns into %20. This is where things quietly break — double-encoding happens when a URL that's already been encoded gets encoded again, turning %20 into %2520, and the server sees a literal "%20" instead of a space. Debugging this usually involves staring at a URL and counting percent signs. The symbol evolved from an abbreviation of "per cento" in Italian commercial manuscripts, where a scribal shorthand for "per 100" gradually compressed into the ÷-like glyph with two small circles representing the zeros. UTF-8 encodes it as a single byte 0x25. Unicode classifies it as Po (Punctuation, Other) with the name PERCENT SIGN. The per-mille sign ‰ (U+2030) and per-ten-thousand sign ‱ (U+2031) are its rarer siblings, occasionally mistaken for it in financial documents.
int pct = 85;printf("Progress: %d%%\n", pct); // %% prints a literal %int bucket = pct % 10; // modulo for bucketing
RFC 3986 chose % as the escape character for URLs. Any byte can be represented as %XX where XX is the hex value — so a space becomes %20. The % was picked because it rarely appears in natural text and was available on all keyboards.
In most languages, % is the modulo operator (remainder after division). In Python, % also formats strings ('Hello %s' % name). In CSS, % is a relative unit (width: 50%). In SQL, % is a wildcard in LIKE patterns (LIKE '%search%').
For positive numbers, they're identical. For negatives, they can differ: -7 % 3 is -1 in C/JavaScript (remainder) but 2 in Python (true modulo). Python's version always returns a non-negative result when the divisor is positive, which is often more useful for cyclic calculations.
Use %% in C, Python, and most printf-style formatters — the first % escapes the second. Forgetting this is a classic bug: printf(userInput) where userInput contains % causes format string vulnerabilities (reading stack memory). Always use printf('%s', userInput).