Last active
February 19, 2020 16:06
-
-
Save kripod/40594d7677d1885a9f77484e049c4fe7 to your computer and use it in GitHub Desktop.
Optimized Math.imul() for JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function imul2(x, yHi, yLo) { | |
return (((x * yHi) << 16) + x * y) | 0; | |
} | |
function imul(x, y) { | |
return imul2(x, (y >>> 16) & 0xffff, y & 0xffff); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment