I'm interested how to round up double variable to 2 decimal places in some a little bit specific way. What exactly do I mean? Math.Round ( number, 2) works fine but... I have for example number like 17.0449999...
Math.Round(17.044999, 2) // 17.04
But in that case i'd like to get 17.05. I found a way how to do this, for example:
Math.Round(17.044999, 3) // returns 17.045
Math.Round(17.045, 2) // returns 17.05
What I would like to ask is there some other/better/more simple way to do that?
[EDIT]:
I think i found that's kinda strange problem. From the beginning:
We talk about specific number. I have to count 5% from a prize and in that case prize is 340,9. When i do calculations in windows calculator 340,9 * 0.05 the result is 17,045. Same result i get when i do calculations in Excel. But when i do same calculations in C# i get something like 17,04499999998. Which is obviously so close to 17.045 that we could easily round it up. But the point is that i can't round up to 3 decimal places every result, because that might change other results.
Seems that is special case or C# calculations are "too accurate".