Does anyone know how I can get a format string to use bankers rounding? I have been using "{0:c}" but that doesn't round the same way that bankers rounding does. The Math.Round() method does bankers rounding. I just need to be able to duplicate how it rounds using a format string.
Note: the original question was rather misleading, an...
I want to do this using the Math.Round function
...
I'm trying to round a number to it's first decimal place and, considering the different MidpointRounding options, that seems to work well. A problem arises though when that number has sunsequent decimal places that would arithmetically affect the rounding.
An example:
With 0.1, 0.11..0.19 and 0.141..0.44 it works:
Math.Round(0.1, 1) ...
double a = 18.565
return Math.Round(a,2)
..returns 18.57.
For every other number I tried banker's rounding worked as expected, for example Math.Round(2.565,2) returned 2.56.
Any clue why and when that happens?
Is it error or am I missing something about banker's rounding?
Thanks..
...
I am curious about the existence of any "rounding" standards" when it comes to the calculation of financial data. My initial thoughts are to perform rounding only when the data is being presented to the user (presentation layer).
If "rounded" data is then used for further calculations, should be use the "rounded" figure or the "raw" fig...