Added roundDown

Added another round function as required.
This commit is contained in:
meiamsome 2012-08-18 21:56:46 +02:00
parent 9196504c68
commit 80f658e748

View File

@ -65,7 +65,7 @@ public class NumberUtil {
} }
/** /**
* Rounds the number up to two digit points (Can be inaccurate due to using decimal-points) * Rounds the number up to two decimal points (Can be inaccurate due to using decimal-points)
* *
* @param number Number to round * @param number Number to round
* @return Rounded number * @return Rounded number
@ -73,6 +73,15 @@ public class NumberUtil {
public static double roundUp(double number) { public static double roundUp(double number) {
return Math.ceil(number * 100) / 100; return Math.ceil(number * 100) / 100;
} }
/**
* Rounds the number down to two decimal points
*
* @param number Number to round
* @return Rounded number
*/
public static double roundDown(double number) {
return Math.floor(number * 100) / 100;
}
/** /**
* Converts the number (in seconds) to timer-like format, like 2:00 (minutes:seconds) * Converts the number (in seconds) to timer-like format, like 2:00 (minutes:seconds)