We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3d2c6b5 commit 7a1b23aCopy full SHA for 7a1b23a
src/Math.php
@@ -5,6 +5,8 @@
5
use function abs;
6
use function ceil;
7
use function floor;
8
+use function round;
9
+use const PHP_ROUND_HALF_UP;
10
11
/**
12
* Class Math
@@ -42,4 +44,26 @@ public static function abs($value): int
42
44
{
43
45
return (int)abs($value);
46
}
47
+
48
+ /**
49
+ * @param int|float $value
50
+ * @param int $precision
51
+ * @param int $mode
52
+ *
53
+ * @return float
54
+ */
55
+ public static function round($value, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): float
56
+ {
57
+ return (float)round((float)$value, $precision, $mode);
58
+ }
59
60
61
62
63
+ * @return int
64
65
+ public static function roundInt($value): int
66
67
+ return (int)round((float)$value);
68
69
0 commit comments