0

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

Ostap Filipenko
  • 235
  • 5
  • 21

2 Answers2

2
var n = 12.1799999M;
n = Math.Floor(n * 100) / 100;
Magnus
  • 45,362
  • 8
  • 80
  • 118
0

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

amountOfDecimals should be 2 in your case

Steven
  • 1,996
  • 3
  • 22
  • 33