Treat FormCalc Pmt() period parameter as an integer.

Round down just like Acrobat Reader.

Change-Id: Ia5ae2623399b29f6af01af18ceb33186b2778b12
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/90210
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index 8bbecbb..d11ff2a 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -2920,7 +2920,7 @@
   double nPrincipal = ValueToDouble(info.GetIsolate(), argOne);
   double nRate = ValueToDouble(info.GetIsolate(), argTwo);
   double nPeriods = ValueToDouble(info.GetIsolate(), argThree);
-  if (nPrincipal <= 0 || nRate <= 0 || nPeriods <= 0 ||
+  if (nPrincipal <= 0 || nRate <= 0 || nPeriods < 1 ||
       nPeriods > static_cast<double>(std::numeric_limits<int32_t>::max())) {
     pContext->ThrowArgumentMismatchException();
     return;
@@ -2928,7 +2928,7 @@
 
   double nTmp = 1 + nRate;
   double nSum = nTmp;
-  for (int32_t i = 0; i < nPeriods - 1; ++i)
+  for (int32_t i = 0; i < static_cast<int>(nPeriods) - 1; ++i)
     nSum *= nTmp;
 
   info.GetReturnValue().Set((nPrincipal * nRate * nSum) / (nSum - 1));
diff --git a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
index b5cca29..bf9ba04 100644
--- a/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context_embeddertest.cpp
@@ -502,6 +502,7 @@
 
   ExecuteExpectFloat("Pmt(25000, 0.085, 12)", 3403.82145169876f);
   ExecuteExpectFloat("Pmt(5000, 0.01, 1)", 5050);
+  ExecuteExpectFloat("Pmt(5000, 0.01, 1.5)", 5050);
   ExecuteExpectFloat("Pmt(30000.00, .085 / 12, 12 * 12)", 333.01666929435f);
   ExecuteExpectFloat("Pmt(10000, .08 / 12, 10)", 1037.03208935916f);
   ExecuteExpectFloat("Pmt(150000, 0.0475 / 12, 25 * 12)", 855.17604207164f);