Using integers instead of floats with Lua 5.0.2

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Using integers instead of floats with Lua 5.0.2

Zachary P. Landau-4
Hello,

I am in the process in bringing Lua up on a Coldfire board with no
FPU.  By changing the NUMBER= line in the lua 'config' file I was able
to compile Lua with support for using integers instead of floats,
which helped a lot.

Has anyone else done this with a recent version of Lua?  I'm wondering
if it causes any problems with lua itself, as well as any popular
extentions.

Specifically, LuaSocket does not seem to be too happy about it.  For
example, when I tell it to bind to a port using 'socket.bind("*",
1234)' it claims it is listening on port 1084769792, which seems a bit
high for a port number.  The problem showed up in other places, like
socket.time(), as well.

If anyone has some advice for making lua and friends play nicely with
integers, please let me know.

-- 
Zachary P. Landau <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

RE: Using integers instead of floats with Lua 5.0.2

Kevin Baca-2
I'm using 5.1-work0.  These are the #defines I changed:

#define LUA_NUMBER      int
#define LUA_INTEGER     int
#define LUA_NUMBER_SCAN "%d"
#define LUA_NUMBER_FMT  "%d"

#define lua_str2number(s,p)     strtol((s), (p), 10)

-Kevin

> -----Original Message-----
> From: [hidden email] 
> [[hidden email]] On Behalf Of 
> Zachary Landau
> Sent: Thursday, November 04, 2004 2:43 PM
> To: [hidden email]
> Subject: Using integers instead of floats with Lua 5.0.2
> 
> 
> Hello,
> 
> I am in the process in bringing Lua up on a Coldfire board with no
> FPU.  By changing the NUMBER= line in the lua 'config' file I was able
> to compile Lua with support for using integers instead of floats,
> which helped a lot.
> 
> Has anyone else done this with a recent version of Lua?  I'm wondering
> if it causes any problems with lua itself, as well as any popular
> extentions.
> 
> Specifically, LuaSocket does not seem to be too happy about it.  For
> example, when I tell it to bind to a port using 'socket.bind("*",
> 1234)' it claims it is listening on port 1084769792, which seems a bit
> high for a port number.  The problem showed up in other places, like
> socket.time(), as well.
> 
> If anyone has some advice for making lua and friends play nicely with
> integers, please let me know.
> 
> -- 
> Zachary P. Landau <[hidden email]>
> 


Reply | Threaded
Open this post in threaded view
|

Re: Using integers instead of floats with Lua 5.0.2

Adam D. Moss
In reply to this post by Zachary P. Landau-4
Zachary Landau wrote:
Specifically, LuaSocket does not seem to be too happy about it.

Don't forget to recompile LuaSocket (and any other lua module)
with the new number type too.  I made that mistake myself...

--Adam

Reply | Threaded
Open this post in threaded view
|

Re: Using integers instead of floats with Lua 5.0.2

Zachary P. Landau-4
In reply to this post by Zachary P. Landau-4
> Specifically, LuaSocket does not seem to be too happy about it.  For
> example, when I tell it to bind to a port using 'socket.bind("*",
> 1234)' it claims it is listening on port 1084769792, which seems a bit
> high for a port number.  The problem showed up in other places, like
> socket.time(), as well.

The problems I was having with LuaSocket were actually from Lua not
honoring the NUMBER= line for me.   I manually put the USE_INT lines
from etc/luser_number.h into lua.h and it solved my problem.  If I get
a chance I'll try to figure out why it wasn't reading the information
from luser_number.h properly. "-DLUA_USER_H='"../etc/luser_number.h"'
-DUSE_INT " was appearing on the command line when compiling, so I'm
not sure why the problem showed up.

-- 
Zachary P. Landau <[hidden email]>