avoid overflow in mod. fixes #3046
Merge branch 'master' of github.com:JuliaLang/julia