Replace rounding using int(x+0.5) with roundToInt
[alexxy/gromacs.git] / src / gromacs / tools / convert_tpr.cpp
index d4fca39d7412845c44fd8cf7bfb44d139026e790..343fa5525b0ac89db629031cb2eeae90a1bb434c 100644 (file)
@@ -404,7 +404,7 @@ int gmx_convert_tpr(int argc, char *argv[])
         /* Determine total number of steps remaining */
         if (bExtend)
         {
-            ir->nsteps = ir->nsteps - (run_step - ir->init_step) + static_cast<int64_t>(extend_t/ir->delta_t + 0.5);
+            ir->nsteps = ir->nsteps - (run_step - ir->init_step) + gmx::roundToInt64(extend_t/ir->delta_t);
             printf("Extending remaining runtime of by %g ps (now %s steps)\n",
                    extend_t, gmx_step_str(ir->nsteps, buf));
         }
@@ -414,7 +414,7 @@ int gmx_convert_tpr(int argc, char *argv[])
                    gmx_step_str(ir->nsteps, buf),
                    gmx_step_str(run_step, buf2),
                    run_t, until_t);
-            ir->nsteps = static_cast<int64_t>((until_t - run_t)/ir->delta_t + 0.5);
+            ir->nsteps = gmx::roundToInt64((until_t - run_t)/ir->delta_t);
             printf("Extending remaining runtime until %g ps (now %s steps)\n",
                    until_t, gmx_step_str(ir->nsteps, buf));
         }