CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Fri Dec 13, 2019 4:31 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 1 post ] 
Author Message
 Post subject: Iterating over floats
PostPosted: Thu Oct 24, 2013 7:31 am 
Offline
Frequent User
Frequent User
User avatar

Joined: Fri Mar 18, 2011 4:12 pm
Posts: 266
(This is a rephrased example of a case which arrived via email.)

Python has the range() and xrange() constructs to iterate over integers. However, there is no such construct for floats.

The main reason might be the problems with rounding of floats. If you want a good introduction into that subject, you can check the following article: What Every Computer Scientist Should Know About Floating-Point Arithmetic by David Goldberg.

You should also be aware that the FPU on the runtime might handle the precision and rounding different than the Python code on the developer PC, if you're about to compare floating point values between PC and runtime e. G. via monitoring.

If you're aware of said problems, you may find some solutions in the Recipe 66472 in the Python Cookbook, or in the Discussion on Stack Overflow.

_________________
Check out the CODESYS store: http://store.codesys.com/

CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 1 post ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited