lua-users home
lua-l archive

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

>Unfortunately, I need both.  Integers and floats are both used extensively
>for the API, for things like 3D vectors and some basic physics calculations.
>Integers are used for material identifiers and screen coordinates for HUD

But these integers will likely fit in a float, that is, they won't need more
than 16 bits, right?

>For the moment Lua is using floats all the time and I convert these to
>integers in the Lua stub functions - something that is not really ideal.

Are you concerned with speed?
glLua does that all the time and has no problems.

>I think that I will have to take the plunge and duplicate the code for
>Numbers to add Integers.  What I am wondering is if there are any gotchas to
>be aware of whilst doing this.  For example, coercion problems or stuff like

Several gotchas, I guess. You'll have to re-design the whole coercion system.
For instance, how do you decide whether a number should be stored as int or
float? What is the result of 1/2: 0 or 0.5?