Here you can find the source of toDecimal(long val, int places)
public static String toDecimal(long val, int places)
//package com.java2s; public class Main { public static String toDecimal(long val, int places) { StringBuffer buf = new StringBuffer(10 + places); while (places > 0) { buf.append(val % 10); places--;//from w w w. ja va 2 s . c o m val = val / 10; if (places == 0) buf.append('.'); } buf.reverse(); return val + buf.toString(); } }