PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Calculation / MathTrig / Sqrt.php

Sqrt.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Calculation/MathTrig/Sqrt.php

65 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\MathTrig;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled;
6 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Exception;
7
8 class Sqrt
9 {
10 use ArrayEnabled;
11
12 /**
13 * SQRT.
14 *
15 * Returns the result of builtin function sqrt after validating args.
16 *
17 * @param mixed $number Should be numeric, or can be an array of numbers
18 *
19 * @return array<mixed>|float|string square root
20 * If an array of numbers is passed as the argument, then the returned result will also be an array
21 * with the same dimensions
22 */
23 public static function sqrt($number)
24 {
25 if (is_array($number)) {
26 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number);
27 }
28
29 try {
30 $number = Helpers::validateNumericNullBool($number);
31 } catch (Exception $e) {
32 return $e->getMessage();
33 }
34
35 return Helpers::numberOrNan(sqrt($number));
36 }
37
38 /**
39 * SQRTPI.
40 *
41 * Returns the square root of (number * pi).
42 *
43 * @param array<mixed>|float $number Number, or can be an array of numbers
44 *
45 * @return array<mixed>|float|string Square Root of Number * Pi, or a string containing an error
46 * If an array of numbers is passed as the argument, then the returned result will also be an array
47 * with the same dimensions
48 */
49 public static function pi($number)
50 {
51 if (is_array($number)) {
52 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number);
53 }
54
55 try {
56 $number = Helpers::validateNumericNullSubstitution($number, 0);
57 Helpers::validateNotNegative($number);
58 } catch (Exception $e) {
59 return $e->getMessage();
60 }
61
62 return sqrt($number * M_PI);
63 }
64 }
65