fork(14) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. decimal dec = -12345678912345678912345678912.456m;
  8. int digits = GetDigits(dec);
  9. Console.WriteLine(digits.ToString());
  10. }
  11.  
  12. static int GetDigits(decimal dec)
  13. {
  14. decimal d = decimal.Floor(dec < 0 ? decimal.Negate(dec) : dec);
  15. int cnt = 1;
  16. while ((d = decimal.Floor(d / 10m)) != 0m)
  17. cnt++;
  18. return cnt;
  19. }
  20. }
Success #stdin #stdout 0.03s 33856KB
stdin
Standard input is empty
stdout
29