-- see http://l...content-available-to-author-only...s.org/wiki/ReadWriteFormat -- Write an integer in MSB order using width bytes. function numbertobytes(num, width) local function _n2b(t, width, num, rem) if width == 0 then return table.concat(t) end table.insert(t, 1, string.char(rem * 0x100)) return _n2b(t, width-1, math.modf(num/0x100)) end return _n2b({}, width, math.modf(num/0x100)) end io.write("<", numbertobytes(0x61626364, 4), ">\n")