Code Monkey home page Code Monkey logo

Comments (5)

TheFern2 avatar TheFern2 commented on August 17, 2024

Hi there, the value is exactly how is stored in the plc and how floating values are handled in general in programming/cpus. The plc software just shows you 1 or 2 points of precision.

Have a look at this tutorial, I would probably use round or f string under the second example.

https://www.geeksforgeeks.org/precision-handling-python/

from pylogix.

TheFern2 avatar TheFern2 commented on August 17, 2024

Here is a bit of an explanation on floating storage for 32bit cpu just as a general explanation why floating values have long precision. In short they're stored as binary numbers.

https://stackoverflow.com/questions/7644699/how-are-floating-point-numbers-stored-in-memory

Another from python docs.

https://docs.python.org/3/tutorial/floatingpoint.html

It’s important to realize that this is, in a real sense, an illusion: you’re simply rounding the display of the true machine value.

from pylogix.

wksriaanc avatar wksriaanc commented on August 17, 2024

Hi there, the value is exactly how is stored in the plc and how floating values are handled in general in programming/cpus. The plc software just shows you 1 or 2 points of precision.

Have a look at this tutorial, I would probably use round or f string under the second example.

https://www.geeksforgeeks.org/precision-handling-python/

Hi, Fernando. I thought this might be the case. Thank you for the tutorial - I'll have a look.

from pylogix.

wksriaanc avatar wksriaanc commented on August 17, 2024

Here is a bit of an explanation on floating storage for 32bit cpu just as a general explanation why floating values have long precision. In short they're stored as binary numbers.

https://stackoverflow.com/questions/7644699/how-are-floating-point-numbers-stored-in-memory

Another from python docs.

https://docs.python.org/3/tutorial/floatingpoint.html

It’s important to realize that this is, in a real sense, an illusion: you’re simply rounding the display of the true machine value.

Thank you again, Fernando. Agree with your observation - I've got no intention to round the floating values since they're as mentioned by yourself, the true value :)

from pylogix.

TheFern2 avatar TheFern2 commented on August 17, 2024

Here is a bit of an explanation on floating storage for 32bit cpu just as a general explanation why floating values have long precision. In short they're stored as binary numbers.
https://stackoverflow.com/questions/7644699/how-are-floating-point-numbers-stored-in-memory
Another from python docs.
https://docs.python.org/3/tutorial/floatingpoint.html

It’s important to realize that this is, in a real sense, an illusion: you’re simply rounding the display of the true machine value.

Thank you again, Fernando. Agree with your observation - I've got no intention to round the floating values since they're as mentioned by yourself, the true value :)

You're welcome. Glad to be able to help!

from pylogix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.