Last active
December 15, 2015 09:28
-
-
Save manpages/5238143 to your computer and use it in GitHub Desktop.
Bit masks with leading zeros in Ruby
This file contains hidden or 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
def lz(number, symbols=90, arity=2) | |
unpadded = number.to_s arity | |
padded = '0' * (symbols - unpadded.length) + unpadded | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment