Skip to content

Reading a real tag - possible issue? #121

Answered by ottowayi
sdmolt asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah that is because of how floating points are represented in binary. Here is a doc that explains more about how Python handles floats. The plc is doing some rounding to show you the closest approximate value and python does the same when you type .1 or 1/10. But, since I'm using the struct module to unpack the floating point value from bytes, I don't think it will do the rounding for the string representation. One thing I could do is change the repr for the Tag objects to round to a certain number of decimal places, but then it would be to a fixed number of decimals for every object.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sdmolt
Comment options

Answer selected by sdmolt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants