LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Subtract Function error

Solved!
Go to solution
I use Labview Subtract Function and experiencing something that looks like failure. 1. Two numbers A = 0.15 and B = 0.1. 2. A-B = 0.05. 3. Check if A-B = 0.05 labview answer is no. 4. This is because the Subtract function has released a value that is 0.05 + 13.8778a. Are there others who have experienced this? Tips to fix? Please see attached labview code I use Labview 14.0.1f3 (32-bit)
0 Kudos
Message 1 of 5
(3,743 Views)

See real picture:

0.15 not 0.15 but 0.14999999...

su, if you want check A=B, you need check (A-B)<delta

 

binary.png

Message 2 of 5
(3,726 Views)
Solution
Accepted by G_K_R

To add to this, it's not a LabVIEW specific problem. Floating point errors are something you are going to have to take into consideration for any language. I linked a pretty good video explaining what is happening.

 

https://www.youtube.com/watch?v=PZRI1IfStY0

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 5
(3,717 Views)

PS.  Putting your about screen on your VI really doesn't help us.  And then putting a decoration box over your serial number to hide it really doesn't hide it.  We just need to move things to see the info you were hiding.

0 Kudos
Message 4 of 5
(3,707 Views)

Thanks for fast and good help 🙂

0 Kudos
Message 5 of 5
(3,697 Views)