mardi 29 décembre 2020

Avoid rounding with std::setprecision [duplicate]

the following example

int main(int argc, const char * argv[]) {
    std::stringstream ss;
    ss << std::fixed << std::setprecision(5) << 4567.9000990;
    cout << ss.str() << endl;
}

And when I run it the output is:

4567.90010

I was expecting the output: 4567.90009

Is there any way to avoid rounding in this situation?

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire