aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/core')
-rw-r--r--src/Java/gtPlusPlus/core/util/math/MathUtils.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java
index a46bd8c61d..b61af67566 100644
--- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java
+++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java
@@ -197,6 +197,20 @@ public class MathUtils {
}
return result;
}
+
+
+ //Smooth Rounding Function
+ /**
+ * Returns a long.
+ * The returned number is d rounded to the nearest flat long.
+ * Supports Doubles as input.
+ *
+ * @param current Current value.
+ * @return long Rounded value.
+ */
+ public static long roundToClosestLong(final double d) {
+ return (long) (Math.round(d * 2) / 2.0);
+ }
/**