Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static double changep2(double i) { // TODO Auto-generated method stub BigDecimal b = new BigDecimal(i); int saveBitNum = 2; double c = b.setScale(saveBitNum, BigDecimal.ROUND_HALF_UP).doubleValue(); return c; } }