Here you can find the source of percentTotal(double value, double total)
public static String percentTotal(double value, double total)
//package com.java2s; /**/* w w w .j a v a 2 s . c om*/ * Colloid project * * Combat log analyzer. * * copyright: (c) 2013 by Darek <netmik12 [AT] gmail [DOT] com> * license: BSD, see LICENSE for more details */ import java.text.DecimalFormat; public class Main { public static String percentTotal(double value, double total) { if (total <= 0) { return "0%"; } final DecimalFormat df = new DecimalFormat("#.00"); double result = (value * 100) / total; if (result > 0.01) { return df.format(result); } return "0.00"; } }