the maximum value may be -1 when cast to an (int), do the cast in the
other direction after first making sure the supplied value is positive.