[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: NaN trick
- From: Peter Cawley <lua@...>
- Date: Wed, 6 Jul 2011 17:24:54 +0100
On Wed, Jul 6, 2011 at 4:57 PM, Michael Rose <michael.h.rose@web.de> wrote:
> I think it should also work on current AMD 64bit platforms. This would reduce a Lua value
> from 16 bytes down to 8 bytes on the Lua stack and within tables!
Though you then need to get slightly more creative about encoding the
type. A double has 52 bits of mantissa; with 48 taken for a
pointer-sized value, and 1 taken to ensure a quiet NaN, you only have
3 bits left to encode the type. If you borrow the sign bit as well,
then you have 4 bits. For reference, the current implementation in 5.2
beta uses 6 bits for encoding type.