I need to implement a decimal to chars converter. I have 26 chars available, so it's about converting an integer to base 26 system and then, changing each number to it's alphabet counterpart. I don't want to use the characters 0-9 in the final result string. I can use to_s()
method and this is how it goes:
82.to_s(26) #=> "34" / which gives me "de"
120.to_s(26) #=> "4g" / which should give me "aep", but it's not
Ruby to_s()
method returns a value in a format that is not helpful. Number 82 is converted fine, but conversion of 120 returns a value I have no idea how to handle.
Could anyone explain how I can make the 120 convertion (as an example) return aep
equivalent? In other words, how to convert from decimal base to 26 but without using numbers in output?
to_i
, but your code hasto_s
instead. I have no idea what you are writing about. – Glorify