Why does float f = 3.14; and float f = 3.14f; print the same value in C even though one is double and the other is float?
02:35 15 Nov 2025

I am confused about the following behavior in C.

#include 

int main() {
    float a = 3.14;   // literal is double
    float b = 3.14f;  // literal is float

    printf("%f\n", a);
    printf("%f\n", b);
}

So my confusion is:

  1. If one literal is double and the other is float, why do both print the same output?

  2. Does the implicit conversion from double → float lose precision? If yes, why can’t I see the difference in printf("%f")?

  3. Is there any practical difference between writing 3.14 vs 3.14f for a float variable?

I want to understand the exact reason from a C programming perspective—how literals, implicit conversions, and printf formatting interact.

Thanks.

c