Skip to content

Commit

Permalink
Merge pull request #4107 from oleibman/pr848
Browse files Browse the repository at this point in the history
RATE Function Permits Floating Point NPER
  • Loading branch information
oleibman authored Jul 30, 2024
2 parents ae2c3ea + b6ff857 commit 523afe5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static function rate(
$guess = ($guess === null) ? 0.1 : Functions::flattenSingleValue($guess);

try {
$numberOfPeriods = CashFlowValidations::validateInt($numberOfPeriods);
$numberOfPeriods = CashFlowValidations::validateFloat($numberOfPeriods);
$payment = CashFlowValidations::validateFloat($payment);
$presentValue = CashFlowValidations::validatePresentValue($presentValue);
$futureValue = CashFlowValidations::validateFutureValue($futureValue);
Expand Down Expand Up @@ -193,7 +193,7 @@ public static function rate(
return $close ? $rate : ExcelError::NAN();
}

private static function rateNextGuess(float $rate, int $numberOfPeriods, float $payment, float $presentValue, float $futureValue, int $type): string|float
private static function rateNextGuess(float $rate, float $numberOfPeriods, float $payment, float $presentValue, float $futureValue, int $type): string|float
{
if ($rate == 0.0) {
return ExcelError::NAN();
Expand Down
12 changes: 12 additions & 0 deletions tests/data/Calculation/Financial/RATE.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
-250,
5000,
],
[
0.017929869399484,
24.99,
-250,
5000,
],
[
0.016581855,
24.5,
-250,
5000,
],
[
0.016550119066711999,
24,
Expand Down

0 comments on commit 523afe5

Please sign in to comment.