Last active
November 19, 2016 00:39
-
-
Save a-eid/4a92b4bddf4fe6c5e72a4174e5f56fe2 to your computer and use it in GitHub Desktop.
example base conversion
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
function toBase(number , base){ | |
var s = "" | |
do{ | |
// binary reads from right to left | |
s = String(number % base) + s | |
number = Math.floor(number / base) | |
}while (number > 0) | |
return s | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment