LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug? Two Doubles not detected as equal v8.6

Try this:

 

-  Create a while loop

-  Wire in a double, 0.

-  Make this value a shift register

-  Inside the while loop, continously add .1

-  Also, wire the shifted value to a "Equals?" comparison

-  Wire this to stop the while loop when the shift register equals 1

 

I've attempted this a few times and LabVIEW will never show the values as equal once the shift register reaches 1.0. 

0 Kudos
Message 1 of 33
(5,838 Views)
Please read some widely available information on how floating point values are stored in computers. Such as Wikipedia. This is not a bug. It's called the real world.
Message 2 of 33
(5,831 Views)

Seriously?

 

If you're not going to contribute in a productive manner, why waste your time? 

0 Kudos
Message 3 of 33
(5,821 Views)
Those idiots at National Instruments! What were they thinking leaving such a simple bug undetected for so many years!!!
And he did contribute, check out the link he left. It explains why doubles can't be compared. When they are stored in memory they are not always exactly = eventhough they appear to be to the user.
Message Edited by for(imstuck) on 02-04-2010 03:58 PM
0 Kudos
Message 4 of 33
(5,816 Views)

smercurio's delivery may have been abrupt, but his message was accurate.  This question has been asked countless times on the NI Forums regarding LabVIEW (I imagine a search for DBL equal would yield a fair number of results), and has been undoubtedly asked on forums for other programming languages, too.  When comparing DBL values, you have to do so with some sort of epsilon (error) taken into account, as DBLs are rarely "equal" as far as computers are concerned.

Message Edited by Darren on 02-04-2010 03:58 PM
0 Kudos
Message 5 of 33
(5,812 Views)

dre99gsx wrote:

Seriously?

 

If you're not going to contribute in a productive manner, why waste your time? 


Your attitude is ridiculous.

 

That is the answer.  There is nothing more that can be said that can help you.

 

I think you should quick wasting our time and your time by starting to look for another line of work.  Perhaps something where your cheerful personality can be an asset.

Message Edited by Ravens Fan on 02-04-2010 05:01 PM
0 Kudos
Message 6 of 33
(5,806 Views)

If you are talking about something like I have did, it works fine to me:

doubles.jpg

---

While evaluating my code please have in mind that I am a LV novice. Therefore sometimes my code might violate some coding rules that I have to learn about myself. But how else could I do that... 🙂

Chart zoom with "Mouse Over" effect
0 Kudos
Message 7 of 33
(5,804 Views)

Giedrius.S wrote:

If you are talking about something like I have did, it works fine to me:

doubles.jpg


 

won't always work i believe
0 Kudos
Message 8 of 33
(5,797 Views)
He was adding 0.1, not 1.  That is where you especially get into floating point roundoff errors as you get through 0.9
0 Kudos
Message 9 of 33
(5,791 Views)

Giedrius.S wrote:

If you are talking about something like I have did, it works fine to me:

doubles.jpg


Read the threads, integers are fine, there is an exact binary representation (except for 1 perhaps Smiley Wink ) , try something like 0.1.

Message Edited by Darin.K on 02-04-2010 02:05 PM
0 Kudos
Message 10 of 33
(5,784 Views)