Code example for BigDecimal

Methods: floatValuesetScale

0
	public static float round(float value) {
 
		float roundedValue = Math.round(value);
		float fark = (float) Math.abs(value - roundedValue);
 
		BigDecimal bd = new BigDecimal(Float.toString(fark));
		bd = bd.setScale(5, BigDecimal.ROUND_HALF_EVEN);
 
		if (bd.floatValue() == 0)
			return roundedValue;
		else 
			return value;
	} 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE