File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
src/org/openpatch/scratch Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 6
6
7
7
## 4.15.2
8
8
9
+ - 🚀 Feat: add Operators.round(value, precision) to round values. ` Operators.round(2.3456, 2) ` will return ` 2.35 ` .
9
10
- 🐛 Fix: Random.randomInt not return the maximum value.
10
11
11
12
## 4.15.1
Original file line number Diff line number Diff line change @@ -154,6 +154,17 @@ public static final int round(double x) {
154
154
return (int ) Math .round (x );
155
155
}
156
156
157
+ /**
158
+ * Rounds a number to a specified number of decimal places.
159
+ * @param x a value
160
+ * @param precision the number of decimal places to round to
161
+ * @return the rounded value
162
+ */
163
+ public static final double round (double x , int precision ) {
164
+ double scale = Math .pow (10 , precision );
165
+ return Math .round (x * scale ) / scale ;
166
+ }
167
+
157
168
/**
158
169
* "mod" is an abbreviation for "modulo". Modulo returns the remainder when the first input is
159
170
* divided by the second input.
You can’t perform that action at this time.
0 commit comments