[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Hex constant definition
- From: Matthew Paul Del Buono <delbu9c1@...>
- Date: Mon, 22 Sep 2008 12:32:29 -0400 (EDT)
>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?
>
I think you're missing what you're actually trying to do. These do two radically different things (and I would like to stress that I doubt that the second is actually what you're trying to do).
If you want a 3-byte integer* containing the value 0xD3A8AF, then you were right in what you did the first time.
If you want a string containing the decimal values of each byte stuck on top of each other (I can't think of any valid need for this, but it could theoretically be needed), then the second is what you intended to do.
These two blocks of code do radically different things and I'm not sure you understand your problem fully :) Explain exactly what you're trying to do instead of just that it "doesn't work" and then we might be able to clarify better.
Regards,
-- Matthew P. Del Buono
* Semantics: This is actually a double in vanilla Lua, however for all intents and purposes in this example it acts as a 3 byte integer.