Skip to content

Instantly share code, notes, and snippets.

@aarondufall
Last active December 27, 2015 06:39
Show Gist options
  • Save aarondufall/7283586 to your computer and use it in GitHub Desktop.
Save aarondufall/7283586 to your computer and use it in GitHub Desktop.
function decToBin(num, acc){
var acc = acc || ""
if (Math.floor(num) == 0) {
console.log(parseInt(acc))
return parseInt(acc)
}
acc = Math.floor(num % 2) + acc
decToBin(num / 2, acc)
}
decToBin(253)// == 11111011)
decToBin(153)// == 10011001)
decToBin(22)// == 10100)
@danktec
Copy link

danktec commented Nov 3, 2013

it seems kinda buggy tho, did you test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment