webmcp
diff libraries/mondelefant/mondelefant_atom_connector.lua @ 419:8b8ebcb87034
Bugfix in mondelefant_atom_connector: Properly handle big numbers (integer and non-integer)
author | jbe |
---|---|
date | Tue Jan 12 18:23:40 2016 +0100 (2016-01-12) |
parents | fb98b17056e5 |
children | b29e082cafb8 |
line diff
1.1 --- a/libraries/mondelefant/mondelefant_atom_connector.lua Sat Jan 09 19:40:39 2016 +0100 1.2 +++ b/libraries/mondelefant/mondelefant_atom_connector.lua Tue Jan 12 18:23:40 2016 +0100 1.3 @@ -43,11 +43,16 @@ 1.4 end 1.5 1.6 input_converters["number"] = function(conn, value) 1.7 - local str = tostring(value) 1.8 - if string.find(str, "^[0-9%.e%-]+$") then 1.9 - return str 1.10 + local integer_string = string.format("%i", value) 1.11 + if tonumber(integer_string) == value then 1.12 + return integer_string 1.13 else 1.14 - return "'NaN'" 1.15 + local number_string = tostring(value) 1.16 + if string.find(number_string, "^[0-9.e+-]+$") then 1.17 + return number_string 1.18 + else 1.19 + return "'NaN'" 1.20 + end 1.21 end 1.22 end 1.23