Re: Pass int64
Niki Bowe <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
James Porter wrote:
> Niki Bowe wrte:
>
>> Done correctly that is the best solution. Itll allow you to do
>> arithmetic on 64 bit integers in lua.
>> Though there is a bit more to it than that.
>> lua_Number will need to be able to hold int64 values without loss.
>> which means youll need to either go with int64 as lua_Number (ie integer
>> only lua)
>> or long double as lua_Number (non portable. no guarantee it can
>> represent all 64 bit ints.
>>
>
> Are you sure about this? Because that would imply that Lua 5.1 doesn't
> work properly when compiled for a 64-bit platform since, by default,
> LUA_INTEGER is #defined to ptrdiff_t. That seems like something the Lua
> developers would have considered, but maybe not...
>
> - Jim
>
Lua certainly works on 64 bit platforms.
It just doesnt do what you might expect. depending on what you expect.
The problem here is that lua_Number (by default) is set to double.
and internally lua values are represented by the following union
/*
** Union of all Lua values
*/
typedef union {
GCObject *gc;
void *p;
lua_Number n;
int b;
} Value;
Internally when you push an integer it casts it to lua_Number. (see the
code for lua_pushinteger).
So if you want to be able to represent any 64 bit integer in lua you
will have to do one of the things I suggested in a previous email.
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user