lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>Maybe I should restate my question:
>
>How do I define a 3 byte hex constant of 'D3A8AF', or more generally, of any
>length using the normal hex characters of 0-F?
>

The correct answer to do this would be something along the lines of:

local foo = 0xD3A8AF;

Which you had originally.

If you have some string that you need to parse into this, you can also do it in this manner:

local str = "D3A8AF";
local bar = tonumber(str, 16); -- 16 == base
assert(bar == foo);

Regards,
-- Matthew P. Del Buono