easy Ruby base conversion
Fixnum.to_s accepts an integer parameter specifying what base you want it to represent in.
16.to_s(16)
=> "10"
255.to_s(16)
=> "ff"
You can get really crazy with this cheez-whiz though:
24.to_s(25)
=> "9k"
35.to_s(36)
=> "z"
but not too crazy...
36.to_s(37)
ArgumentError: invalid radix 37
Written by Aaron H
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#