Java examples for java.lang:double
get Percentage from two double value
//package com.java2s; import java.math.BigDecimal; public class Main { public static void main(String[] argv) throws Exception { double part = 2.45678; double whole = 2.45678; System.out.println(getPercentage(part, whole)); }//from w w w .j a v a 2 s.c om public static BigDecimal getPercentage(double part, double whole) { return new BigDecimal(part * 100 / whole); } }