10進数to16進数

10進数を16進数に変換します.
16で割っていくわけです.
そのまま.もっとよさそうなのがあるんじゃないの感がぷんぷん
ただし,1280.to_s(16)はナシの方向です.

def decimalToHex(decimal)
	i = 0
	b = ""
	while(decimal != 0 || i >= 0) do 
		a = (decimal / 16**i)
		if a < 16
			case a
				when 10:	b += "a"
				when 11:	b += "b"
				when 12:	b += "c"
				when 13:	b += "d"
				when 14:	b += "e"
				when 15:	b += "f"
				else b += a.to_s
			end
			decimal -= a * 16**i
			i -= 1
		else
			i += 1
		end
	end
	return b

end
p decimalToHex(256)

>"100"