Converting an integer to a hexadecimal string in Ruby
You can give to_s a base other than 10: 10.to_s(16) #=> “a” Note that in ruby 2.4 FixNum and BigNum were unified in the Integer class. If you are using an older ruby check the documentation of FixNum#to_s and BigNum#to_s