fork(16) download
  1. class Main {
  2. public static void niceround(double x) {
  3. System.out.println(x+" to " + Math.ceil(x * Math.pow(10, -Math.floor(Math.log10(x)))) / Math.pow(10, -Math.floor(Math.log10(x))));
  4. }
  5. public static void main(String[] args) {
  6. niceround(0.0322);
  7. niceround(3.22);
  8. niceround(32.2);
  9. niceround(42.2);
  10. niceround(422.2);
  11. }
  12. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
0.0322 to 0.04
3.22 to 4.0
32.2 to 40.0
42.2 to 50.0
422.2 to 500.0