rounding error - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: rounding error (/showthread.php?tid=912) |
rounding error - rocfusion - 22.07.2017 Hi Admin, It's acceptable the Logic Machine has to store values with a rounding error. It's more worrying when stored values with rounded errors cannot returned back to the KNX bus with the correct value. For example, a floating point number of 103 is stored as 102.96. I use rounding function to restore the value back to 103, now if I use grp.response or grp.write to return 103 back to KNX bus, I see in the ETS group monitor 102.96. Even if I try, grp.repsonse('1/1/1',103), then the ETS monitor displays 102.96 Can you please correct the grp.response and grp.write functions? Thanks, Roger RE: rounding error - admin - 24.07.2017 Roger, can you provide a full example and which data type are you using? RE: rounding error - rocfusion - 24.07.2017 Hi Admin, I have tested with 2 byte floating point and the temperature variant. So create just an object of 2 byte floating point. then write an event script for this new object that looks like, if(event.type='groupwrite')then grp.write(event.dst,103) elseif (event.type=='groupread')then grp.response(event.dst, 103) end Then use ETS to monitor the LM, in both cases 102.96 is sent on the bus. thanks, Roger RE: rounding error - admin - 24.07.2017 If you try writing 103 with ETS you will get 103.04. The thing is that it's not possible to encode 103 as a 2-byte float value, you either get 102.96 or 103.04. If you need better precision then use 4-byte float if your devices support it. RE: rounding error - buuuudzik - 24.07.2017 Because of this thing every KNX display has an option to round a value to a specified number of digits after the decimal point. |