Here you can find the source of round(float amount, int cent)
public static float round(float amount, int cent)
//package com.java2s; //License from project: Open Source License public class Main { public static float round(float amount, int cent) { if (cent <= 0) { throw new IllegalArgumentException("cent must be greater than 0"); }/* w ww. j a v a 2s . co m*/ int roundAmount = Math.round(amount * 100.0f); int x = roundAmount % cent; int discount = 0; if (x > cent / 2.0f) { discount = cent - x; } else { discount = -x; } return (roundAmount + discount) / 100.0f; } public static float round(float amount) { return Math.round(amount * 100.0f) / 100.0f; } }