PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
← All changes | includes/sdk/google/brick/math/src/RoundingMode.php +12 -20 1.2.91.4.1 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2
3 3 declare (strict_types=1);
4 -namespace Dudlewebs\WPMCS\Brick\Math;
4 +namespace Dudlewebs\WPMCS\GCP\Brick\Math;
5 5
6 6 /**
7 7 * Specifies a rounding behavior for numerical operations capable of discarding precision.
8 8 *
@@ -11,25 +11,17 @@
11 11 * exact numerical result, the discarded digits will be referred to as the discarded fraction
12 12 * regardless the digits' contribution to the value of the number. In other words, considered
13 13 * as a numerical value, the discarded fraction could have an absolute value greater than one.
14 14 */
15 -final class RoundingMode
15 +enum RoundingMode
16 16 {
17 17 /**
18 - * Private constructor. This class is not instantiable.
19 - *
20 - * @codeCoverageIgnore
21 - */
22 - private function __construct()
23 - {
24 - }
25 - /**
26 18 * Asserts that the requested operation has an exact result, hence no rounding is necessary.
27 19 *
28 20 * If this rounding mode is specified on an operation that yields a result that
29 21 * cannot be represented at the requested scale, a RoundingNecessaryException is thrown.
30 22 */
31 - public const UNNECESSARY = 0;
23 + case UNNECESSARY;
32 24 /**
33 25 * Rounds away from zero.
34 26 *
35 27 * Always increments the digit prior to a nonzero discarded fraction.
@@ -34,9 +26,9 @@
34 26 *
35 27 * Always increments the digit prior to a nonzero discarded fraction.
36 28 * Note that this rounding mode never decreases the magnitude of the calculated value.
37 29 */
38 - public const UP = 1;
30 + case UP;
39 31 /**
40 32 * Rounds towards zero.
41 33 *
42 34 * Never increments the digit prior to a discarded fraction (i.e., truncates).
@@ -41,9 +33,9 @@
41 33 *
42 34 * Never increments the digit prior to a discarded fraction (i.e., truncates).
43 35 * Note that this rounding mode never increases the magnitude of the calculated value.
44 36 */
45 - public const DOWN = 2;
37 + case DOWN;
46 38 /**
47 39 * Rounds towards positive infinity.
48 40 *
49 41 * If the result is positive, behaves as for UP; if negative, behaves as for DOWN.
@@ -48,9 +40,9 @@
48 40 *
49 41 * If the result is positive, behaves as for UP; if negative, behaves as for DOWN.
50 42 * Note that this rounding mode never decreases the calculated value.
51 43 */
52 - public const CEILING = 3;
44 + case CEILING;
53 45 /**
54 46 * Rounds towards negative infinity.
55 47 *
56 48 * If the result is positive, behave as for DOWN; if negative, behave as for UP.
@@ -55,9 +47,9 @@
55 47 *
56 48 * If the result is positive, behave as for DOWN; if negative, behave as for UP.
57 49 * Note that this rounding mode never increases the calculated value.
58 50 */
59 - public const FLOOR = 4;
51 + case FLOOR;
60 52 /**
61 53 * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
62 54 *
63 55 * Behaves as for UP if the discarded fraction is >= 0.5; otherwise, behaves as for DOWN.
@@ -62,27 +54,27 @@
62 54 *
63 55 * Behaves as for UP if the discarded fraction is >= 0.5; otherwise, behaves as for DOWN.
64 56 * Note that this is the rounding mode commonly taught at school.
65 57 */
66 - public const HALF_UP = 5;
58 + case HALF_UP;
67 59 /**
68 60 * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
69 61 *
70 62 * Behaves as for UP if the discarded fraction is > 0.5; otherwise, behaves as for DOWN.
71 63 */
72 - public const HALF_DOWN = 6;
64 + case HALF_DOWN;
73 65 /**
74 66 * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards positive infinity.
75 67 *
76 68 * If the result is positive, behaves as for HALF_UP; if negative, behaves as for HALF_DOWN.
77 69 */
78 - public const HALF_CEILING = 7;
70 + case HALF_CEILING;
79 71 /**
80 72 * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards negative infinity.
81 73 *
82 74 * If the result is positive, behaves as for HALF_DOWN; if negative, behaves as for HALF_UP.
83 75 */
84 - public const HALF_FLOOR = 8;
76 + case HALF_FLOOR;
85 77 /**
86 78 * Rounds towards the "nearest neighbor" unless both neighbors are equidistant, in which case rounds towards the even neighbor.
87 79 *
88 80 * Behaves as for HALF_UP if the digit to the left of the discarded fraction is odd;
@@ -91,6 +83,6 @@
91 83 * Note that this is the rounding mode that statistically minimizes
92 84 * cumulative error when applied repeatedly over a sequence of calculations.
93 85 * It is sometimes known as "Banker's rounding", and is chiefly used in the USA.
94 86 */
95 - public const HALF_EVEN = 9;
87 + case HALF_EVEN;
96 88 }