Course contentsShow
← C
Lesson 228 of 1,2193. Operators and ExpressionsFree lesson

Implicit promotion to `int`

Implicit promotion to int

What you'll learn: Why C secretly upgrades small whole numbers like char and short to int before doing any math.

The "Middleman" Rule

Imagine you are at a local grocery store. You can pay with pennies, nickels, or dimes, but the cash register only calculates totals in whole dollars. Before the machine does any math, it must convert those tiny coins into a standard dollar format.

C handles small integer types exactly like this. In an expression, types smaller than an int—specifically char and short—are almost never used "as is" for math. Instead, C automatically promotes them to a full-sized int before the calculation happens. This is known as integer promotion.

Why does this happen?

Your computer’s CPU is designed to work most efficiently with its "native" word size. For most modern systems, that is at least 32 bits (an int). It is actually more work for the processor to try and do math on a tiny 8-bit char than it is to simply pad that byte with zeros (or sign bits) and treat it like a standard integer.

By promoting everything to an int, C ensures that the math is fast and that you are less likely to "overflow" (run out of room) during intermediate steps of a calculation.

Seeing promotion in action

Even if you add two small variables and store the result in a small variable, the math in the middle happens at the int level.

#include <stdio.h>

int main() {
    char a = 100;
    char b = 50;
    
    // Even though 'a' and 'b' are chars, C promotes them 
    // to ints before adding them together.
    // Result of (a + b) is the integer 150.
    int result = a + b;

    printf("Result: %d", result);
    return 0;
}

In this example, the CPU doesn't see two characters. It sees two integers, adds them, and then—if you were to save it back into a char—it would squeeze that result back down into the smaller box.

Why it matters

This behavior usually stays hidden, but it explains why your code doesn't break when you perform operations on different small types. C is constantly "leveling up" your data to the standard int size to keep calculations consistent and fast.

Key takeaway

C automatically promotes char and short types to int during expressions to match the CPU's native processing power.