lua-users home
lua-l archive

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


On Tue, Jun 9, 2015 at 3:12 PM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> On 9 June 2015 at 13:00, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>>> My implementation is on 64-bit machine with 64-bit integers - so it
>>> can work on 64-bit.
>>
>> How do you do that??
>>
>
> I overlay the double with the type code.
>
> So the structure looks like this:
>
> |------ first 8 bytes ----------| |------- second 8 bytes -------|
>   value other than double        type code (int) union
>   including 64-bit int                 with double
>
> Since the size of the value object is 16 bytes anyway it doesn't
> change the overall size.
>
> Regards
> Dibyendu
>

Isn't this basically the "NaN trick" that some versions of Lua used?
If the value is NaN, certain bits encode type information; otherwise
it's a double?

-- 
Sent from my Game Boy.