Created
September 14, 2019 12:52
-
-
Save RMuskovets/3c72571d083fb3c544bcecd3f10fde4b to your computer and use it in GitHub Desktop.
This is a very small parseInt realisation in 153 bytes written in JavaScript.
This file contains 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
const parseInt=(s,r=10)=>{const a=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; | |
const as=a.slice(0,r+1);let v=0,n=s[0]=='-';for (let i=n?1:0;i<s.length;i++)v=v*r+as.indexOf(s[i]);if(n)v*=-1;return v}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment