02-04-2010 04:06 PM
I have dealt with this in C++, so to me it isn't new, but the strange part is this.
If I remove the shift-register value and instead wire in a constant double of 1.1 (lets say), and compare two 1.1 values, I get a TRUE. It is when I compare the shif-register value that it never registers TRUE.
So, the question here is if given the precision problem, does labview treat a shift register differently than a constant? I can work around this by rounding or using "Greater-or-Equal".
02-04-2010 04:07 PM
02-04-2010 04:07 PM
dre99gsx wrote:Seriously?
If you're not going to contribute in a productive manner, why waste your time?
Why waste our time by not searching the forums to see if a question like what you're asking has already been posted. Which it has. Countless times.
I have very little patience for people who don't even bother to do a little bit of work on their own. Perhaps it's that I'm old enough to remember when there WASN'T an internet and people had to find answers the HARD way. Like research.
02-04-2010 04:10 PM
Darin.K wrote:Read the threads, integers are fine, there is an exact binary representation (except for 1 perhaps ) , try something like 0.1.
Message Edited by Darin.K on 02-04-2010 02:05 PM
My bad. I am not used to such format like ".1". I have read it as "1". Sorry.
02-04-2010 04:15 PM
dre99gsx wrote:I have dealt with this in C++, so to me it isn't new, but the strange part is this.
If I remove the shift-register value and instead wire in a constant double of 1.1 (lets say), and compare two 1.1 values, I get a TRUE. It is when I compare the shif-register value that it never registers TRUE.
So, the question here is if given the precision problem, does labview treat a shift register differently than a constant? I can work around this by rounding or using "Greater-or-Equal".
It is irrelevant whether you use a shift register or any other construct. Just because it happens to work without a shift register and it doesn't happen to work with a shift register is completely meaningless. You're still trying to perform an equality on floating point values.
02-04-2010 04:15 PM
dre99gsx wrote:I have dealt with this in C++, so to me it isn't new, but the strange part is this.
If I remove the shift-register value and instead wire in a constant double of 1.1 (lets say), and compare two 1.1 values, I get a TRUE. It is when I compare the shif-register value that it never registers TRUE.
So, the question here is if given the precision problem, does labview treat a shift register differently than a constant? I can work around this by rounding or using "Greater-or-Equal".
Not at all strange and it has nothing to do with the shift register. It has everything to do with the add. You add an imprecise representation to another imprecise representation and .1 + .1 does not equal .2. You will have exactly the same problem in every other programming language.
02-04-2010 04:19 PM - edited 02-04-2010 04:20 PM
I don't think your issue is that you are using a shift register, but more a case where you are accumulating an error until it finally shows up.
You can do a comparison where 1 = 1, but if you add some math and do a 1 /3 x 3, the result is not 1 but .99999. Comparing constants is like the first case, comparing the result of a calculation (adding .1 over and over again) is like the second case. Adding .1 ten times does not yield a precise 1.
02-04-2010 04:26 PM
-------
It is irrelevant whether you use a shift register or any other construct. Just because it happens to work without a shift register and it doesn't happen to work with a shift register is completely meaningless. You're still trying to perform an equality on floating point values.
------
Great, I think that answers the question. I was under the impression LabVIEW was being "smart" about this since it worked well in some odd cases. When it suddenly didn't work, I began to rethink the operation. I will probably subtract the two values and look for a few decimal place range of error to determine if the value is equal or not.
Thanks for the input.
09-18-2013 08:31 AM - edited 09-18-2013 08:32 AM
I am supprised at the number of condesending people there are in the NI fourms...
But by the way
in matlab
a = 0.5
b = 0.5
a==b will give 1
a and b are both doubles.
labview is supposed to be a high level language like matlab and it would be expected this functionality is built in.
So clearly this is a grose oversite by NI I would expect this feature to be built in.
09-18-2013 08:38 AM
I'm constantly amazed at how many people who don't unerstand computers try to program one. There is no GROSS oversight at all and I don't believe that matlab does anything differently. Your simplified example works in LabVIEW as well.