04-26-2010 09:48 AM - edited 04-26-2010 09:51 AM
Solved! Go to Solution.
04-26-2010 09:53 AM
Please do a search on "equality", "LabVIEW", "floating point", "I found a bug in LabVIEW!", "LabVIEW can't do math!"
Also, http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems.
The Search 1D Array works by performing equality comparisons.
04-26-2010 09:55 AM
Search 1D Array uses an "equal" as comparation. It is always a bad idea to compare floating point numbers with equal.
There are plenty of threads on this forum covering this issue. (example here).
This is not a LV issue (see here).
hope this helps,
Norbert
04-26-2010 09:55 AM
The problem is the way floating-point numbers are represented in binary. You can find many discussions on the subject of comparing two floating-point numbers on this forum. One good explanation is at: http://digital.ni.com/public.nsf/allkb/B01682241DD825948625665100663F61
04-26-2010 09:58 AM
Welcome to the world of floats and doubles. The precision is good, but not infinite giving these symptoms every so often.
04-26-2010 10:05 AM
The VI is right, btw. Increasing visible number of decimals you'll notice you compare 0,58723354278 to 0,587234 which will never be true.
04-26-2010 10:11 AM
Hi Singh,
The 2 numbers you have arent equal:
Number in array is actually: 0.5872335427799636, you can see this by altering the display format.
Its to do with how the double value is stored on the computer.
I use an array called 'Approx Equals' that compares numbers to a specified decimal place:
I have attached the 'Approx Equals' vi. As said you can specify the accuracy of the comparison.
Rgs,
Lucither
04-27-2010 12:16 AM - edited 04-27-2010 12:17 AM
04-27-2010 12:16 AM