Skip to content

Instantly share code, notes, and snippets.

@sanmadjack
Last active August 29, 2015 13:56
Show Gist options
  • Save sanmadjack/8790248 to your computer and use it in GitHub Desktop.
Save sanmadjack/8790248 to your computer and use it in GitHub Desktop.
A JavaScript function that takes a decimal-format number and outputs the D'Ni (base-25) equivalent digits. Returns an array containing integer representations of each D'Ni digit.
function convertToDni(number) {
var new_number = new Array();
// If the number is just 0, then we just save some time and output a zero
if(number==0) {
new_number.unshift(0);
return new_number;
}
// D'Ni is base-25, so we divide by 25 over and over again, depositing the remainders into the new number,
// until the number is finally less than 25 (meaning dividing it by 25 floors to 0
while(number>0) {
new_number.unshift(number%25);
number = Math.floor(number/25);
}
return new_number;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment