PluginProbe
Media Cloud Sync / 1.3.11
Media Cloud Sync v1.3.11
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 1.3.0 All 34 releases
media-cloud-sync / includes / sdk / google / brick / math / src / RoundingMode.php

RoundingMode.php in Media Cloud Sync 1.3.11, at includes/sdk/google/brick/math/src/RoundingMode.php

89 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace Dudlewebs\WPMCS\GCP\Brick\Math;
5
6 /**
7 * Specifies a rounding behavior for numerical operations capable of discarding precision.
8 *
9 * Each rounding mode indicates how the least significant returned digit of a rounded result
10 * is to be calculated. If fewer digits are returned than the digits needed to represent the
11 * exact numerical result, the discarded digits will be referred to as the discarded fraction
12 * regardless the digits' contribution to the value of the number. In other words, considered
13 * as a numerical value, the discarded fraction could have an absolute value greater than one.
14 */
15 enum RoundingMode
16 {
17 /**
18 * Asserts that the requested operation has an exact result, hence no rounding is necessary.
19 *
20 * If this rounding mode is specified on an operation that yields a result that
21 * cannot be represented at the requested scale, a RoundingNecessaryException is thrown.
22 */
23 case UNNECESSARY;
24 /**
25 * Rounds away from zero.
26 *
27 * Always increments the digit prior to a nonzero discarded fraction.
28 * Note that this rounding mode never decreases the magnitude of the calculated value.
29 */
30 case UP;
31 /**
32 * Rounds towards zero.
33 *
34 * Never increments the digit prior to a discarded fraction (i.e., truncates).
35 * Note that this rounding mode never increases the magnitude of the calculated value.
36 */
37 case DOWN;
38 /**
39 * Rounds towards positive infinity.
40 *
41 * If the result is positive, behaves as for UP; if negative, behaves as for DOWN.
42 * Note that this rounding mode never decreases the calculated value.
43 */
44 case CEILING;
45 /**
46 * Rounds towards negative infinity.
47 *
48 * If the result is positive, behave as for DOWN; if negative, behave as for UP.
49 * Note that this rounding mode never increases the calculated value.
50 */
51 case FLOOR;
52 /**
53 * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
54 *
55 * Behaves as for UP if the discarded fraction is >= 0.5; otherwise, behaves as for DOWN.
56 * Note that this is the rounding mode commonly taught at school.
57 */
58 case HALF_UP;
59 /**
60 * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
61 *
62 * Behaves as for UP if the discarded fraction is > 0.5; otherwise, behaves as for DOWN.
63 */
64 case HALF_DOWN;
65 /**
66 * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards positive infinity.
67 *
68 * If the result is positive, behaves as for HALF_UP; if negative, behaves as for HALF_DOWN.
69 */
70 case HALF_CEILING;
71 /**
72 * Rounds towards "nearest neighbor" unless both neighbors are equidistant, in which case round towards negative infinity.
73 *
74 * If the result is positive, behaves as for HALF_DOWN; if negative, behaves as for HALF_UP.
75 */
76 case HALF_FLOOR;
77 /**
78 * Rounds towards the "nearest neighbor" unless both neighbors are equidistant, in which case rounds towards the even neighbor.
79 *
80 * Behaves as for HALF_UP if the digit to the left of the discarded fraction is odd;
81 * behaves as for HALF_DOWN if it's even.
82 *
83 * Note that this is the rounding mode that statistically minimizes
84 * cumulative error when applied repeatedly over a sequence of calculations.
85 * It is sometimes known as "Banker's rounding", and is chiefly used in the USA.
86 */
87 case HALF_EVEN;
88 }
89