Adjusting decimal precision, .net

Preserving trailing zeroes like this was introduced in .NET 1.1 for more strict conformance with the ECMA CLI specification.

There is some info on this on MSDN, e.g. here.

You can adjust the precision as follows:

  • Math.Round (or Ceiling, Floor etc) to decrease precision (b from c)

  • Multiply by 1.000… (with the number of decimals you want) to increase precision – e.g. multiply by 1.0M to get b from a.

Leave a Comment