double d = 123456.789; DecimalFormat df = new DecimalFormat("#,##0.00"); System.out.println(df.format(d)); 四舍五入保留2位小数: String.format("%.2f", value); JS中数字的计算,第一个方法用于计算,第二个用于千分位显示 Math.formatFloat = function (f, digit) { var m = Math.po…
前言 为了获得一堆apk的大小,并与人类友好方式显示.本来是打算用以下方法,到时不能具体到保留两位小数. org.apache.commons.io.FileUtils.byteCountToDisplaySize(f.length()); Returns a human-readable version of the file size, where the input represents a specific number of bytes. If the size is over 1GB…