C Rounding One-Liner

Of course you can use the math libraries and actually round, but this is a quick one-liner that truncates to two digits.

fValue = static_cast<int>(fValue * 100) / 100.0;

Leave a Reply

Your email address will not be published. Required fields are marked *