Change checking to use integer arithmetic to avoid roundoff error problems