Does setprecision in c++ round? If so why am I seeing this?

The number 0.298475 isn’t representable exactly in a double (since it’s not a fraction whose denominator is a power of two, being 11939/40000), and the actual number that is stored is actually closer to 0.29847 than to 0.29848.

Leave a Comment