lua-users home
lua-l archive

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


I know that the question of numbers in Lua have been discussed
frequently in the Lua-list in the past, but I do not think this
specific question has been addressed.

As I understand it, Lua is set up to have one basic sort
of number, LUA_NUMBER, by default 'double', which is used
internally and to which other sorts of number are cast
automatically.

What I want is a somewhat different arrangement, because the
CPU I use (XScale) is not equipped with FP ops or FP
coprocessor. For that reason, I set LUA_NUMBER to int
(32 bit in my set up). However I would also like to be able
to use fp numbers (32 bit again) as a separate sort of
number (identified by presence of a decimal point in
numeric literals). I want a single, explicit, int2fp cast
function, and no implicit casting.

I can certainly see my way to modifying the sources to get this,
but before I launch myself into activity I thought that I had better
ask advice. Lots of people may have done this already. What is the best
way of getting what I want with the least discourteous hackery to the
sources as they stand?

PS. I know that implicit type conversions are very useful in awk,
and that it has become traditional to use them in scripting
languages. However, making explicit all type conversions from int to fp
(or double, or ... ) is also a useful regime in some circumstances,
so it would be nice to be able to make such a choice in luaconf.h.

-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/