avoid using Math.abs

review comment on - c6f5311
To avoid overflow issues and unnecessary calls to Math.abs.