Added round(double d, int numDecimal) function
@@ -215,6 +215,15 @@ public class TypeUtil
return getDouble(obj, defaultValue, true);
}
+ /**
+ * Round specified value to specified number of decimal.
+ */
+ public static double round(double d, int numDecimal)
+ {
+ final double pow = Math.pow(10, numDecimal);
+ return Math.round(d * pow) / pow;
+ }
+
/**
* Swap all nibbles in given 32bit int
*/
