Why the double type variable in C can't store the digit '7'?

Copper Contributor

I tested a double variable in C to store the value '12345678901234567'. But it can't store the last digit '7' and shows it as '8'. However, if I change the last digit to '6' or '8', then it can show the same value. What is that?


Here is the program:


#include <stdio.h>

int main()
    double a;
    a = 12345678901234567;

    printf("%lf", a);

    return 0;
Output: 12345678901234568.000000


0 Replies