Skip to content

Instantly share code, notes, and snippets.

@pjc0247
Created April 21, 2014 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjc0247/11130652 to your computer and use it in GitHub Desktop.
Save pjc0247/11130652 to your computer and use it in GitHub Desktop.
def to_binary_u(n, fit=8)
bin = ""
while n > 0
bin = (n % 2).to_s + bin
n /= 2
end
return bin.rjust(fit, '0')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment