lua-users home
lua-l archive

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


On Fri, Jan 26, 2007 at 10:34:32AM +0100, Mike Pall wrote:
> > Floating point numbers locale bug. Lua needs some dirty hacks to keep your
> > scripts working when using floating point numbers.
> 
> Well, that page seems to have grown into a flamefest. Anyway, the
> statement is simply untrue. Lua 5.1 deals with this properly:
> 
> $ lua
> Lua 5.1  Copyright (C) 1994-2006 Lua.org, PUC-Rio
> > = 1.2
> 1.2
> > os.setlocale("de_DE@euro", "numeric")
> > = 1.2
> 1,2

I assumed that the above (vague, flamey) note on the wiki was referring
to this, and that he (whoever he was) had scripts that expected tostring()
and tonumber() to use period separators--not a particularly unreasonable
expectation.  If people are going to spend their time complaining about
Lua on the wiki, it'd be nice if they'd go the extra mile and make it
clear what they're complaining about ...

> I don't think that setting the numeric locale is a good idea in
> general. But Lua's parser still works. It has an explicit
> workaround for parsing floating-point numbers in non-standard
> locales.

The behavior is perhaps unexpected and poorly thought out, from
an API standpoint, but it is not, as far as I know, nonstandard.

-- 
Glenn Maynard