Explictly cast calculation to int, to allow std::max to work.
Merge pull request #2695 from robbak/init_cpp-explicit_cast

Explictly cast calculation to int, to allow std::min to work.