I would like to remove any zeros from the end of an integer. For example, if I have
14260, I would like to end up with
142600 I would also like to end up with
I have had a look around and can't find a solution for integers, just a lot of people talking about removing leading zeros and zeros from floats.
convert to string, sub and convert back to int:
142600.to_s.sub(/0+$/,'') # /0+$/ is regex to find all trailing 0s #=> "1426" 14200006000000000.to_s.sub(/0+$/,'').to_i #=> 14200006