0

Why the float values are different from double values when set precision on std::cout ??

    std::cout << std::setprecision(20) << endl;
    float num = 1.2;
    cout <<  num << endl;
    double num2 = 1.2;
    cout <<  num2 << endl;

Output:

1.2000000476837158203
1.1999999999999999556
Jarod42
  • 203,559
  • 14
  • 181
  • 302

0 Answers0