Here you can find the source of divide(Long d1, Long d2)
public static String divide(Long d1, Long d2)
//package com.java2s; /*//from w w w.j a v a 2 s . co m * Copyright 2014 Alibaba.com All right reserved. This software is the * confidential and proprietary information of Alibaba.com ("Confidential * Information"). You shall not disclose such Confidential Information and shall * use it only in accordance with the terms of the license agreement you entered * into with Alibaba.com. */ import java.text.DecimalFormat; public class Main { public static String divide(Long d1, Long d2) { if (d1 == null || d2 == null || d2.equals(0l)) { return "0"; } double percent = (double) d1 / d2; DecimalFormat format = new DecimalFormat("0.00"); return format.format(percent); } }