This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

Datatype values
#1
Hi

I got a minor problem, im using LM to calculate energy usage for a building and the send them a html report on mail every first every month. Im almost finished, but there is one issue im wondering if there is an easy solution to.
Im using schneider IEM3455 and powertags. The IEM uses 8byte int for energy and this is okey, but the powertag uses 4byte float, and that means it uses comma values.


My script saves values every month to the LM storage, and pulls it out and compares it at the end of the month.
But when its saved to the storage it save it with all the comma values, is there a way to prevent this easly?

Above one is from 4 byte float and the lowest is the 8 byte int


[Image: 1uCBguJ.png]

Example of mail:
[Image: 11kqvZh.png]
Reply
#2
You can use string.format to convert floating point number to a string with fixed decimals places in your html report:
Code:
num = 12.3456789
val = string.format('%.3f', num) -- 3 decimal places
log(val) -- will output 12.346
Reply
#3
(11.02.2020, 12:18)admin Wrote: You can use string.format to convert floating point number to a string with fixed decimals places in your html report:
Code:
num = 12.3456789
val = string.format('%.3f', num) -- 3 decimal places
log(val) -- will output 12.346

Thanks that did it Big Grin
Reply


Forum Jump: