I have this
131.988
I want
132
how can I accomplish this?
Microsoft help documentation does not specify the precise mathematical
operation that is used when format specifiers convert decimal non-
integral numbers to integer strings. So string formatting cannot be
relied upon as means of rounding.
The System.Math class on the other have a function Round which
conforms to an IEEE standard and so can be used reliably for this
purpose.
Thus
double x = 131.988
int y = Math.Round(x)
will yield a properly rounded integer result (whatever value x happens
to be), which can then be converted to a string if desired.
This is important because there are various regimes that can be used
when the decimal lies mid way between two integers e.g. what do you do
in the case of 131.5 ? According to the IEEE standard if the lower
integer is odd then round up otherwise round down (hence 131.5 rounds
to 132 whereas 132.5 rounds to 132 rather than 133).