vendredi 23 juin 2017

Why the float values are different from double values when set precision? [duplicate]

This question already has an answer here:

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

Aucun commentaire:

Enregistrer un commentaire