fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. incrementCellCounter(1);
  13. incrementCellCounter(5);
  14. incrementCellCounter(9);
  15. incrementCellCounter(10);
  16. incrementCellCounter(11);
  17. incrementCellCounter(45);
  18. incrementCellCounter(56);
  19. incrementCellCounter(99);
  20. incrementCellCounter(100);
  21. incrementCellCounter(101);
  22. incrementCellCounter(500);
  23. incrementCellCounter(999);
  24. incrementCellCounter(1000);
  25. incrementCellCounter(1001);
  26. incrementCellCounter(9999);
  27. incrementCellCounter(10000);
  28. incrementCellCounter(10001);
  29. }
  30.  
  31. private static void incrementCellCounter(int numCells) {
  32. final int bucketSize = ((int) Math.ceil(Math.log10(numCells))) * 10;
  33. int bucket = (numCells / bucketSize);
  34. int bucketStart = bucket * bucketSize;
  35. int bucketEnd = bucketStart + (bucketSize - 1);
  36. System.out.println(String.format("%d - bucket_feature_in_num_cells_%05d_to_%05d",
  37. numCells, bucketStart, bucketEnd));
  38. }
  39. }
Runtime error #stdin #stdout #stderr 0.07s 380160KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArithmeticException: / by zero
	at Ideone.incrementCellCounter(Main.java:33)
	at Ideone.main(Main.java:12)