Created
January 1, 2015 12:18
-
-
Save tjstebbing/442957697c8cff0eaa69 to your computer and use it in GitHub Desktop.
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 numberToToken(int) { | |
| return Number('10000'+int).toString(36); | |
| } | |
| function tokenToNumber(token) { | |
| return Number((parseInt(token, 36)+'').slice(4)); | |
| } | |
| var num = 123; | |
| console.log('starting with', num); | |
| var token = numberToToken(num); | |
| console.log('makes token', token); | |
| console.log('and back to', tokenToNumber(token)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment