Here you can find the source of powerString(int power)
public static String powerString(int power)
//package com.java2s; //License from project: Open Source License public class Main { public static String powerString(int power) { float scaledPower = Math.abs(power); String unit;/*from w ww . ja va 2 s. c o m*/ if (power >= 1000000) {//1 million Endergy = 1mE (megaEndergy) scaledPower /= 1000000; unit = "mE"; } else if (power >= 1000) {//1 thousand Endergy = 1kE (kiloEndergy) scaledPower /= 1000; unit = "kE"; } else { unit = "E"; } String string = (power < 0 ? "-" : "") + String.valueOf(scaledPower); if (scaledPower == Math.floor(scaledPower) && string.contains(".")) {//If it's a whole number, just return the whole part. string = string.substring(0, string.indexOf('.')); } else { if (string.length() > 4) string = string.substring(0, 4);//Truncate to two decimal points } return string + unit; } }