例子1: var num = "112233.99887766";console.log(num.substring(0,(num.indexOf(".")+5)));返回:112233.9988 例子2: var item = "https://www.oss-cn-hangzhou.aliyuncs.com/www20190107/e220d0f66c8a643c8e16dc9aa01f51b3194/箱数.png";console.log(
import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.NumberFormat; public class format { double f = 111231.5585; public void m1() { BigDecimal bg = new BigDecimal(f); double f1 = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubl
BigDecimal bd = new BigDecimal(0.0199999999999); System.out.println("res:"+bd.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); DecimalFormat df = new DecimalFormat("#.00"); System.out.println(df.format(Double.parseDouble(str))); S
function changeTwoDecimal_f(x) { var f_x = parseFloat(x); if (isNaN(f_x)) { alert('function:changeTwoDecimal->parameter error'); return false; } var f_x = Math.round(x * 100) / 100; var s_x = f_x.toString(); var pos_decimal = s_x.indexOf('.'); if (po