PluginProbe
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin / 6.5.1.7
wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin v6.5.1.7
6.5.1.7 6.5.1.6 6.5.1.5 6.5.1.4 6.5.1.3 6.5.1.2 6.5.1.1 6.5.0.9 6.5.0.8 6.5.0.7 6.5.0.6 trunk 3.4.2.40 3.4.2.41 3.4.2.42 3.4.2.43 3.4.2.44 3.4.2.45 3.4.2.46 3.4.2.47 3.4.2.48 3.4.2.49 3.4.2.50 6.3.2 6.3.3.1 All 47 releases
wpdatatables / lib / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Calculation / Engineering / Compare.php

Compare.php in wpDataTables – WordPress Data Table, Dynamic Tables & Table Charts Plugin 6.5.1.7, at lib/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Calculation/Engineering/Compare.php

83 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Calculation\Engineering;
4
5 use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
6 use PhpOffice\PhpSpreadsheet\Calculation\Exception;
7
8 class Compare
9 {
10 use ArrayEnabled;
11
12 /**
13 * DELTA.
14 *
15 * Excel Function:
16 * DELTA(a[,b])
17 *
18 * Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise.
19 * Use this function to filter a set of values. For example, by summing several DELTA
20 * functions you calculate the count of equal pairs. This function is also known as the
21 * Kronecker Delta function.
22 *
23 * @param array|float $a the first number
24 * Or can be an array of values
25 * @param array|float $b The second number. If omitted, b is assumed to be zero.
26 * Or can be an array of values
27 *
28 * @return array|int|string (string in the event of an error)
29 * If an array of numbers is passed as an argument, then the returned result will also be an array
30 * with the same dimensions
31 */
32 public static function DELTA($a, $b = 0.0)
33 {
34 if (is_array($a) || is_array($b)) {
35 return self::evaluateArrayArguments([self::class, __FUNCTION__], $a, $b);
36 }
37
38 try {
39 $a = EngineeringValidations::validateFloat($a);
40 $b = EngineeringValidations::validateFloat($b);
41 } catch (Exception $e) {
42 return $e->getMessage();
43 }
44
45 return (int) (abs($a - $b) < 1.0e-15);
46 }
47
48 /**
49 * GESTEP.
50 *
51 * Excel Function:
52 * GESTEP(number[,step])
53 *
54 * Returns 1 if number >= step; returns 0 (zero) otherwise
55 * Use this function to filter a set of values. For example, by summing several GESTEP
56 * functions you calculate the count of values that exceed a threshold.
57 *
58 * @param array|float $number the value to test against step
59 * Or can be an array of values
60 * @param null|array|float $step The threshold value. If you omit a value for step, GESTEP uses zero.
61 * Or can be an array of values
62 *
63 * @return array|int|string (string in the event of an error)
64 * If an array of numbers is passed as an argument, then the returned result will also be an array
65 * with the same dimensions
66 */
67 public static function GESTEP($number, $step = 0.0)
68 {
69 if (is_array($number) || is_array($step)) {
70 return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $step);
71 }
72
73 try {
74 $number = EngineeringValidations::validateFloat($number);
75 $step = EngineeringValidations::validateFloat($step ?? 0.0);
76 } catch (Exception $e) {
77 return $e->getMessage();
78 }
79
80 return (int) ($number >= $step);
81 }
82 }
83