0

I have the following snippet

        cout.precision(30);
        long double d = 85952643841691072928.0;
        cout << d << endl;

The print statement outputs 85952643841691074560. Why are the last 4 digits before the decimal incorrect? A long double should be capable of handling a number of this size?

roulette01
  • 1,984
  • 2
  • 13
  • 26
  • Also: https://stackoverflow.com/questions/43655668/are-all-integer-values-perfectly-represented-as-doubles – NathanOliver Sep 17 '20 at 19:27
  • If a `long double` is 80 bits IEEE 754 on your platform, then the precision is only 18-21 digits. –  Sep 17 '20 at 19:27
  • 1
    You can ask what precision it has, q.v.: https://stackoverflow.com/a/50970282/4641116 – Eljay Sep 17 '20 at 19:31

0 Answers0