I suggest using this method :
public static int GetNumberOfDecimalPlaces(decimal value, int maxNumber)
{
if (maxNumber == 0)
return 0;
if (maxNumber > 28)
maxNumber = 28;
bool isEqual = false;
int placeCount = maxNumber;
while (placeCount > 0)
{
decimal vl = Math.Round(value, placeCount - 1);
decimal vh = Math.Round(value, placeCount);
isEqual = (vl == vh);
if (isEqual == false)
break;
placeCount--;
}
return Math.Min(placeCount, maxNumber);
}