integers anyone?

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

integers anyone?

David Jeske-2
Hey all,

Okay, I know this has come up as a discussion before, and the general
concensus was that integers were not necessary. However, I'm starting to
use Lua in a project where not having integers is going to make my life
difficult. I think lua is the right tool for the job, but it'll be much
nicer if Lua has integers.

I'm integrating Lua as an init/config/script/interactive edit language for
a board level hardware debugger. I've been running into problems with data
conversion going from U32 -> double -> write(format("%X",num)); 

I think it's mostly a problem with format() loosing precision. However, I
really need to be able to deal with bit math and also I need to be able to
enter hex constants and such into lua scripts.

I may end up using a userdata type for the time being. However, I would
much prefer not to have to do something like:

number = integer("0x44544a"); 

within all my Lua code. 



Can we resurrect the integer discussion? 

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: integers anyone?

Luiz Henrique de Figueiredo
>From [hidden email] Mon May 11 23:26:47 1998
>
>Okay, I know this has come up as a discussion before, and the general
>concensus was that integers were not necessary. However, I'm starting to
>use Lua in a project where not having integers is going to make my life
>difficult. I think lua is the right tool for the job, but it'll be much
>nicer if Lua has integers.

if you do not need real numbers, then you can #defeine real to be long
and everything should work, in Lua 3.1.

>I think it's mostly a problem with format() loosing precision. However, I
>really need to be able to deal with bit math and also I need to be able to
>enter hex constants and such into lua scripts.
>
>I may end up using a userdata type for the time being. However, I would
>much prefer not to have to do something like:
>
>number = integer("0x44544a"); 
>
>within all my Lua code. 

In 3.1, you can also write X"0x44544a". this is sugar for X("0x44544a").
--lhf

Reply | Threaded
Open this post in threaded view
|

Re: integers anyone?

David Jeske-2
On Tue, May 12, 1998 at 09:14:06AM -0300, Luiz Henrique de Figueiredo wrote:
> >Okay, I know this has come up as a discussion before, and the general
> >concensus was that integers were not necessary. However, I'm starting to
> >use Lua in a project where not having integers is going to make my life
> >difficult. I think lua is the right tool for the job, but it'll be much
> >nicer if Lua has integers.
> 
> if you do not need real numbers, then you can #defeine real to be long
> and everything should work, in Lua 3.1.

I did this, and it is still uncapable of handling unsigned 32bits.

#define real unsigned long

In C I do:   lua_pushnumber(0xFeBff008);

In Lua, I do:   write(format("0x%X",num));

I get:

0x80000000

> In 3.1, you can also write X"0x44544a". this is sugar for X("0x44544a").

That will help, thanks.

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + [hidden email]