I want to do this using the Math.Round
function
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
If you'd like a string
Or a decimal
But remember! Rounding is not distributive, ie.
round(x*y) != round(x) * round(y)
. So don't do any rounding until the very end of a calculation, else you'll lose accuracy.I know its an old question but please note for the following differences between Math round and String format round:
// convert upto two decimal places
=========
can also combine "0" with "#".
Here's some examples:
You might also want to look at bankers rounding / round-to-even with the following overload:
There's more information on it here.
Try this: