Round double off with 2 digits after comma - C#

Viewed 38

I have the number 12.1799999 and it should become 12.17 How does it work in c#?

2 Answers
var n = 12.1799999M;
n = Math.Floor(n * 100) / 100;

If you intent to round down, then use Math.Floor(number, amountOfDecimals)

amountOfDecimals should be 2 in your case

Related