Create remainder.js

lots of edge cases here...