Use the correct values for int max and min

We had accidentally gone one power of two too far. In addition, we need
to handle minimum values as well as the maximum.