Why do you mod by MaxValue? Any casting to integer will have similar behavior. This will not make attemptId positive, for instance, but nor is it likely for a stage to be reattempted more than 2 billion times.