04-22-2016 03:19 AM
Hello every one,
I am calling this subVI from the main.
I am geting this weird error calculation. Can anyone tell me what is wrong please?
Why am I getting A false while it should be a true?
Thanks,
Regards,
F
04-22-2016 03:32 AM - edited 04-22-2016 03:34 AM
Hi F,
the wonders of floating point numbers!
In the screenshot you just see rounded float values. And believe me: 10.9999 is smaller than 11.0001!
There are a lot of threads on the topic of floating point precision. And all of them say: be careful when adding 0.8 and 0.2, the result might be different than 1.0!
04-22-2016 03:44 AM
04-22-2016 03:47 AM
@feriel0209 wrote:Hello every one,
I am calling this subVI from the main.
I am geting this weird error calculation. Can anyone tell me what is wrong please?
Why am I getting A false while it should be a true?
Thanks,
Regards,
F
From looking at your png of the code it is easy to see the confusion you might have.
11.0 is not equal to 11.0! BUT yet I believe there is no error in the calculation! Trust me for a just a "bit" and I will try to explain. This might be a "Wrap-your-head-in-duct_tape-moment" the FULL explaination is not easy.
It is simple to understand if, you remember that computers cannot understand the infinate amount of "Whole numbers" you understand and can only deal with "Floating point" numbers. Yes, "Whole numbers" like those you learned in grade school and "IEEE-754Floating point numbers" are not the same set of numbers
First; look at this link
What this means to YOU: Unless you have the library I attached to the linked message (or a simillar library) NEVER drive a case structure from a boolean output of a floating point number comparsion!
04-22-2016 04:11 AM
Hi, thanks for your quick answers!
Yeah, but I am not using measuring values. I am just adding 0.2 to the floating voltage values.
I will check what you told me and be back to you.
Regards,
Feriel
04-22-2016 04:40 AM - edited 04-22-2016 04:45 AM
@feriel0209 wrote:Hi, thanks for your quick answers!
Yeah, but I am not using measuring values. I am just adding 0.2 to the floating voltage values.
I will check what you told me and be back to you.
Regards,
Feriel
Just adding 0.2? 0.2 (in "Real") cannot be exactly represented as an IEEE 754 compliant "Float." The fact that. the set of "Foating point numbers" is a very limited sub-set of the set of "Real numbers" causes a lot of confussion. So much confussion that a big bunch of engineers needed to step in and write IEEE 754!
Meaning no offence- you just need to remember your computer just cannot think like a human! On the "Plus-side" that why some humans get paid to write computer software
04-22-2016 05:20 AM
feriel0209 wrote: I am just adding 0.2 to the floating voltage values.
Yeah, and here (Floating Zero) we are just subtracting 0.1 and causing an infinate loop.
And this issue is for every computer language, not just LabVIEW. This is a lesson I learned hard with QBasic.
04-22-2016 06:19 AM
@crossrulz wrote:And this issue is for every computer language, not just LabVIEW. This is a lesson I learned hard with QBasic.
SpoilerI might be dating myself there. But at least it was not punch cards like some of the guys around here.
And now we are going very OT, (that is "Off Topic" a rare idiosyncrasy of these forums that do not usually use "txt spk")
crossrulz was joking with some of his elders (me.) I dress better than he does! I really have used a BIC Flair as a source code control tool. Draw a diagonal line across the card-deck edge and, if you drop the stack, you have a clue to the order they belong in without needing to read the code back into your programming notes.
Yet, it does make a nice point when juxtaposed with the stacked sequence structure issue the OP (Original Poster another rare idiosyncrasy of these forums) presented. Show the code and its output! Just mentioning that some third party software (MS Excel) displays your data "wrong" is really the wrong question to ask.
04-22-2016 07:13 AM - edited 04-22-2016 07:15 AM
Haha I see.
Besides, I understand what you mean. I changed the precision of both numbers and I saw that they are different. (Pic.png)
Thank you for the link.
Regards,
Feriel
04-22-2016 08:04 AM
@JÞB wrote:crossrulz was joking with some of his elders (me.) I dress better than he does!
How do you figure? I have 2 CLA, 1 CLED, and 2 LabVIEW Champion shirts I wear every week. That takes care of my work week! All of those are way better than your stupid CLD shirt.