lua-users home
lua-l archive

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


Those two pieces of code have very different meanings:

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> hunted = 0xD3A8AF
> =hunted, type(hunted)
13871279        number
> h1 = 0xD3; h2 = 0xA8; h3 = 0xAF
> hunted = h1 .. h2 .. h3
> =hunted, type(hunted)
211168175       string

The first piece of code assigns the numeric hex value D3A8AF to
hunted, the second converts each byte of D3A8AF to its decimal form,
converts these to strings and then concatenates the three strings.

2008/9/22 Jeff Wise <jwise@sealyrealty.com>:
> I need to define 3 bytes of hex data. I originally used:
>
>      local hunted = 0xD3A8AF
>
> This gave no errors but the program did not work. When I discovered 'hunted'
> was the culprit, I used:
>
>      local h1 = 0xD3
>      local h2 = 0xA8
>      local h3 = 0xAF
>      local hunted = h1 .. h2 .. h3
>
> This worked. I can not believe this is necessary. What am I missing?
>
>
>
>