Here you can find the source of roundMultiplier(double n)
public static String roundMultiplier(double n)
//package com.java2s; public class Main { public static String roundMultiplier(double n) { if (n >= 0.9) { n = Math.round(n);/*from w w w .j a va 2 s.c o m*/ if (n >= 10) { // Round to nearest multiple of 10. n = Math.round(n / 10) * 10; } if (n >= 100) { // Round to nearest multiple of 10. n = Math.round(n / 100) * 100; } if (n >= 1000) { // Round to nearest multiple of 10.; n = Math.round(n / 1000) * 1000; } return Integer.toString((int) n); } else { String base = roundMultiplier(1. / n); if (base.equals("1")) return base; else return "1/" + base; } } }