I2SBase
not ratedConverts integer i to a string value.
Functions like the native I2S, but it can convert the integer to any base between 2 and 36.
Functions like the native I2S, but it can convert the integer to any base between 2 and 36.
function I2SBase takes integer i, integer base returns string
local string charMap = "0123456789abcdefghijklmnopqrstuvwxyz"
local string s = ""
local integer u = i
local integer d
local boolean n = false
if base < 2 or base > 36 then
return null
elseif base == 10 then
return I2S(i)
endif
if u < 0 then
set n = true
set u = -u
endif
loop
set d = ModuloInteger(u, base)
set u = u / base
set s = SubString(charMap, d, d+1) + s
exitwhen u == 0
endloop
if n then
return "-" + s
endif
return s
endfunctionNo comments.