Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( x === 0 && y ===0 ) return NaN;
- if ( x === y ) return 0;
- if ( x === 0 ) return 0;
- if (x > 0 && y > 0) {
- return x < y ? x : modulo(x-y,y);
- }
- if ( x < 0 && y < 0 ) {
- return x*-1 < y*-1 ? x : modulo(x-y,y);
- }
- if( x > 0 && y < 0 ) {
- return x < y*-1 ? x : modulo(x+y,y);
- }
- if ( x < 0 && y >0) {
- return x*-1 < y ? x : modulo(x+y,y);
- }
Add Comment
Please, Sign In to add comment