00001 package gov.nasa.arc.ase.util;
00002
00003 public class kMG {
00004
00005
00006
00007
00008 private static final long kilo = 1024;
00009 private static final long mega = 1024 * 1024;
00010 private static final long giga = 1024 * 1024 * 1024;
00011
00012 public static String format(long number) {
00013 double value;
00014 String suffix;
00015
00016 if(number >= giga) {
00017 value = ((double)number) / giga;
00018 suffix = "G";
00019 } else if(number >= mega) {
00020 value = ((double)number) / mega;
00021 suffix = "M";
00022 } else if(number >= kilo) {
00023 value = ((double)number) / kilo;
00024 suffix = "k";
00025 } else {
00026 value = (double)number;
00027 suffix = "";
00028 }
00029
00030 value = Math.rint(value * 100) / 100;
00031
00032 return value + suffix;
00033 }
00034 }