Implement more proper numeric range checks, avoiding overflows and such.

I had hoped to put some work into the datetime-related datatypes, but got bogged down in these. Ho hum.