4/13/2021 10:04 AM | |
Joined: 3/9/2021 Last visit: 5/12/2022 Posts: 1 Rating:
|
It seems like you are experiencing a floating-point error; this is due to javascript's number representation (here is an in-depth explanation) Long story short, if you know that your variable should have only a single decimal digit, you could take the reading and apply the "toFixed" function, with 1 as "digits" parameter; here is an example: let myValue = 70.299999899; let myFixedPrecisionValue = myValue.toFixed(1); // "70.3" => keep in mind that this is a string let myFixedPrecisionNumber = Number(myFixedPrecisionValue); // 70.3 Be aware that loss of precision could arise from big numbers (more on that in the article linked) |
This contribution was helpful to
1 thankful Users |
4/13/2021 10:59 AM | |
Joined: 4/28/2015 Last visit: 12/1/2023 Posts: 3294 Rating:
|
Hi, thanks MicheleTogni! @Venomz: For the solution MicheleTogni is describing you need a function node after the S7 node. I attached a simple flow how to do this. Just replace my input node with the S7 node. Just copy the content of the .txt file to clipboard and go to the node-red menu -> Import -> Clipboard and paste it. Best regards! Attachmentlimit_real.txt (219 Downloads) |
Follow us on