fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. double actualCmp=12380030;
  8. int exp = (int)Math.Floor(Math.Log10(Math.Abs(actualCmp)));
  9. if (exp <= 5) actualCmp = (double)Math.Round((decimal)actualCmp, 3);
  10. else
  11. {
  12. int roundFactor = (exp - 5) ;
  13. int round = (int) Math.Pow(10,roundFactor);
  14. Console.WriteLine(roundFactor);
  15. Console.WriteLine(round);
  16. actualCmp = Math.Round((double)actualCmp / (float)round, 0) * round;
  17. }
  18. Console.WriteLine(actualCmp);
  19. }
  20. }
Success #stdin #stdout 0.03s 27144KB
stdin
Standard input is empty
stdout
2
100
12380000