Differences Between: [Versions 400 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\MathTrig; 4 5 use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; 6 use PhpOffice\PhpSpreadsheet\Calculation\Exception; 7 8 class Logarithms 9 { 10 use ArrayEnabled; 11 12 /** 13 * LOG_BASE. 14 * 15 * Returns the logarithm of a number to a specified base. The default base is 10. 16 * 17 * Excel Function: 18 * LOG(number[,base]) 19 * 20 * @param mixed $number The positive real number for which you want the logarithm 21 * Or can be an array of values 22 * @param mixed $base The base of the logarithm. If base is omitted, it is assumed to be 10. 23 * Or can be an array of values 24 * 25 * @return array|float|string The result, or a string containing an error 26 * If an array of numbers is passed as an argument, then the returned result will also be an array 27 * with the same dimensions 28 */ 29 public static function withBase($number, $base = 10) 30 { 31 if (is_array($number) || is_array($base)) { 32 return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $base); 33 } 34 35 try { 36 $number = Helpers::validateNumericNullBool($number); 37 Helpers::validatePositive($number); 38 $base = Helpers::validateNumericNullBool($base); 39 Helpers::validatePositive($base); 40 } catch (Exception $e) { 41 return $e->getMessage(); 42 } 43 44 return log($number, $base); 45 } 46 47 /** 48 * LOG10. 49 * 50 * Returns the result of builtin function log after validating args. 51 * 52 * @param mixed $number Should be numeric 53 * Or can be an array of values 54 * 55 * @return array|float|string Rounded number 56 * If an array of numbers is passed as an argument, then the returned result will also be an array 57 * with the same dimensions 58 */ 59 public static function base10($number) 60 { 61 if (is_array($number)) { 62 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); 63 } 64 65 try { 66 $number = Helpers::validateNumericNullBool($number); 67 Helpers::validatePositive($number); 68 } catch (Exception $e) { 69 return $e->getMessage(); 70 } 71 72 return log10($number); 73 } 74 75 /** 76 * LN. 77 * 78 * Returns the result of builtin function log after validating args. 79 * 80 * @param mixed $number Should be numeric 81 * Or can be an array of values 82 * 83 * @return array|float|string Rounded number 84 * If an array of numbers is passed as an argument, then the returned result will also be an array 85 * with the same dimensions 86 */ 87 public static function natural($number) 88 { 89 if (is_array($number)) { 90 return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); 91 } 92 93 try { 94 $number = Helpers::validateNumericNullBool($number); 95 Helpers::validatePositive($number); 96 } catch (Exception $e) { 97 return $e->getMessage(); 98 } 99 100 return log($number); 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body