Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static float yiweixiaoshu2(String value) { if ("0".equals(value) || "0.0".equals(value) || "0.00".equals(value)) { return 0f; } float a = Float.parseFloat(value); float b = (float) (Math.round(a * 10)) / 10; return b; } public static BigDecimal round(double number, int decimal) { return new BigDecimal(number).setScale(decimal, BigDecimal.ROUND_HALF_UP); } }