
adccommunitymod (AutomationDirect) asked a question.
P2000
Created Date: August 23,2017
Created By: Tecon
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
Hi, I have a problem with Math in P2000. If I need make very large Mathematical example I have a problem with lost data. I´m using result like Float 32-bit I need resaul like 1454781157.21 but I got only this 1.4547E+9. This is a big problem because I lost the important data. There is option how disable conversion to exponent? Thanks
Created Date: August 23,2017
Created by: Tecon
Hi, I have a problem with Math in P2000. If I need make very large Mathematical example I have a problem with lost data. I´m using result like Float 32-bit I need resaul like 1454781157.21 but I got only this 1.4547E+9. This is a big problem because I lost the important data. There is option how disable conversion to exponent?
Thanks
Created Date: August 23,2017
Created by: Frontier
Where are you reading the result? If it's on the HMI, see if you 've got 'disable Exponent Notation ' checked. If you 're reading the result in the Data View in the Productivity Suite, it might just be a limitation of the viewer. Maybe copy it into a 32 bit integer, subtract that from your original float, and display the decimal separately...
Created Date: August 23,2017
Created by: BobO
That's just how floating point works. You trade precision for range. Maximum precision in a 32 bit number is 1 in 4 billion. Doesn't matter whether it's float or integer, that's all you have. Float takes some percentage of that precision and uses to to define a range, which greatly reduces the actual precision.
Created Date: August 23,2017
Created by: franji1
1,454,781,157.21 is more than 32 bit's worth of precision, integer or floating point. You will need 64 bit integer math or double-precision floating point math.
What is the calculation? Can you do it manually in two 32 bit integer values?
What is the maximum range? Billions down to hundredths (as in the example), or is the mathematical range even wider (e.g. trillions down to thousandths, e.g. 1,234,567,890,123.456)?
Created Date: August 23,2017
Created by: GKiser
I´m using result like Float 32-bit I need resaul like 1454781157.21 but I got only this 1.4547E+9. This is a big problem because I lost the important data.
Here's an IEEE-754 floating-point converter that shows why you lose precision. --> https://www.h-schmidt.net/FloatConverter/IEEE754.html
If you enter your value of 1454781157.21 you can see it comes out as 1454781184 and you lose 26.79 due to losing precision.
Created Date: August 24,2017
Created by: Tecon
Thanks, I´m too long from school. Ofcorse there is a mantisa and exponent. Is there another solution of this problem?
Created Date: August 24,2017
Created by: franji1
Thanks, I´m too long from school. Ofcorse there is a mantisa and exponent. Is there another solution of this problem?
How big can your numbers get? To what precision do you require?