Last active
July 2, 2016 13:18
-
-
Save kessler/d0273fd6c191f4ff7746d378e1883ae7 to your computer and use it in GitHub Desktop.
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 toBits(a, res) { | |
if (a === 0) return | |
let r = a % 2 | |
if (r === 0) { res.push(0) } else { res.push(1) } | |
toBits(Math.floor(a / 2), res) | |
} | |
function dec2bin(dec){ | |
return (dec >>> 0).toString(2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment