Trim variable
Posted: Saturday 02 April 2016 18:33
Hi!
I'm using this LUA-script for updating a textfile with temperature from one of my temperaturedevices.
Ii is working but the temperaturevalue has to many decimales, like 2.2999999523163
Is it possible to trim or round the value to maybe 1 decimales, like 2.3
My script:
commandArray = {}
if (devicechanged['Temp Ute_Temperature']) then
temp = devicechanged['Temp Ute_Temperature']
local file = io.open("C:\\Temperature\\temperature.txt", "w")
file:write(temp)
file:close()
end
return commandArray
Greetings
Calle
I'm using this LUA-script for updating a textfile with temperature from one of my temperaturedevices.
Ii is working but the temperaturevalue has to many decimales, like 2.2999999523163
Is it possible to trim or round the value to maybe 1 decimales, like 2.3
My script:
commandArray = {}
if (devicechanged['Temp Ute_Temperature']) then
temp = devicechanged['Temp Ute_Temperature']
local file = io.open("C:\\Temperature\\temperature.txt", "w")
file:write(temp)
file:close()
end
return commandArray
Greetings
Calle