neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
471 stars 76 forks source link

Floating point and culture issues #91

Closed Symbai closed 5 years ago

Symbai commented 5 years ago

NeoLua Version: 1.3.2

There seems to be an issue with float values and culture specific formats. In the example below the float value of "value" parameter is different when used in different culture environments where dot and comma in values have a different meaning. Haven't tested but perhaps this issue also occur on decimal and double types.

Example to reproduce:

local a = 0.4
local b = 0,4
Dostuff(a)
Dostuff(b)

//C#
public static void DoStuff(float value) { ... }

On English culture value it will be: a = 0.4 b = 0

On German culture value will be: a = 0 b = 0.4

But both should be 0.4 otherwise scripts cannot be shared between people living in different countries.

neolithos commented 5 years ago

Lua parses language invariant. see Lua.Runtime.cs:428.

Your example produces on a german culture:

local a = 0.4;
local b = 0,4;
return a,b;

a = 0,4
b = 0

b must be zero, because the 4 assigned to nowhere.