Skip to content

Commit dca855e

Browse files
authored
Add support for using none default base value in log function (#134)
* Update tests with log using base parameter * Ensure base parameter is allowed for log function
1 parent a1f86ab commit dca855e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/NXP/MathExecutor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ protected function defaultFunctions() : array
468468
return $this->execute($falseval);
469469
},
470470
'intdiv' => static fn($arg1, $arg2) => \intdiv($arg1, $arg2),
471-
'ln' => static fn($arg) => \log($arg),
471+
'ln' => static fn($arg1, $arg2 = M_E) => \log($arg1, $arg2),
472472
'lg' => static fn($arg) => \log10($arg),
473-
'log' => static fn($arg) => \log($arg),
473+
'log' => static fn($arg1, $arg2 = M_E) => \log($arg1, $arg2),
474474
'log10' => static fn($arg) => \log10($arg),
475475
'log1p' => static fn($arg) => \log1p($arg),
476476
'max' => static function($arg1, ...$args) {

tests/MathTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public static function providerExpressions()
9797
['hypot(1.5, 3.5)'],
9898
['intdiv(10, 2)'],
9999
['log(1.5)'],
100+
['log(1.5, 3)'],
100101
['log10(1.5)'],
101102
['log1p(1.5)'],
102103
['max(1.5, 3.5)'],
@@ -1148,6 +1149,7 @@ public static function providerExpressionValues()
11481149
['decbin(10)', \decbin(10)],
11491150
['lg(2)', \log10(2)],
11501151
['ln(2)', \log(2)],
1152+
['ln(2, 5)', \log(2, 5)],
11511153
['sec(4)', 1 / \cos(4)],
11521154
['tg(4)', \tan(4)],
11531155
];

0 commit comments

Comments
 (0)