ENG-5277: It's not safe to subtract two longs, cast them to an int,
and hope that the subtraction sign you're using for comparison is
preserved.  Fix the case that caused the reported defect, along with
the other instances I know about.
Merge pull request #837 from VoltDB/eng5277

ENG-5277, re-opened ENG-5212
r=jhugg