[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua5 PalmOS Port (Was: numerical approximations can suck!)
- From: David Jones <drj@...>
- Date: Sat, 22 Nov 2003 14:14:14 +0000
On Nov 21, 2003, at 14:54, José dos Santos Machado wrote:
Lua can bring out problems with the implementation of strtod, for
converting from a printed decimal form to the internal floating point
representation, and printf, for converting from floating point to
printed form, on some platforms. Basically some platforms get the
wrong answers even for apparently simple cases like strtod("113") or
printf("%17d", 14). There is no excuse for this (it's the fault of
the provider of the system C libaries usually) but it can be hard for
users to do anything about it.
I'm having these problems with my PalmOS port of Lua5. I've started
from the scratch again due to lack of the standard libs on PalmOS.
Now, with a newer IDE (cw9), and a few newer routines, I'd like to
compensate these errors on strtod and printf, although I don't know
the lua source very well to know where to change it.
I've tried to put the project on the sf.net without success (I'm a
little lost with that sf.net "cvs-with-putty" thing).
Does anybody have a clue to what files on the Lua5 source do I have to
change to add these number support ?
It turns out that lua is very well organised to do this. Number to
string and string to number conversion is handled by two macros
lua_str2number defined in the file lobject.c
lua_number2str defined in the file lvm.c
Both of these can be redefined. Now all you need is good quality
functions that do these conversion on PalmOS. Perhaps you have that
base already covered? I believe the glibc functions to be adequate.