What's wrong with double?

I was experimenting with data types and found this

ll b = 194949494994994949;
double a = b;
ll c = (ll) a;
cout << b << ’ ’ << c << endl;

The output is :-
194949494994994949 194949494994994944

Value of b and c are different , but why?

1 Like

I think double’s precision value isn’t that long after its precision value it will truncate the number, try using long double. I used long double and it’s giving perfect answer.

you didn’t even google it, right?

1 Like