ENG-5277, re-opened ENG-5212

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.