LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set control's increment programmatically, strange result

Solved!
Go to solution

I have a problem with this VI.
I made it with LV 2009.
There is an auxiliary VI that I utilize to fetch a control's reference programmatically.
The test.vi (main) tries to set a numeric-digital control's  increment programmatically.
With the help of "VI ctrl heap" it is possibile to do all the code in a single big event case.

If you modify "Multiplier N" --> he grabs "Value N", for N = 1, 2, 3, ... , 7
he takes the Multiplier N's value and checks if it is == 1. Then set Value N's increment accordingly.

 

Problem:
it doesn't work as expected.
If you probe the wire, it is all correct untill the equal verification, I cannot understand why it doesn't work.

Thanks for your advices.
Greetings

0 Kudos
Message 1 of 4
(2,763 Views)
Solution
Accepted by topic author Slyfer

The problem is likely due to the equals comparison of non-integer datatypes.  Since fractions like 0.1 cannot be represented exactly in binary, equals comparisons often result in numbers which appear to be equal when displayed to one decimal place are actually different in the 14th, 15th, or 16th place. 

 

Use an approximate comparison: Is the absolute value of the difference less than 10^-14? 

 

Lynn 

Message 2 of 4
(2,752 Views)

Lynn is right, this is probably because of the use of the digital class. If you change the display format of the data indicator to 12 digits you will see that the numbers are not equal.

 

Ben

Message 3 of 4
(2,721 Views)

Ok, you are right, I fixed it.

Explanation is here: Why does my Equal Comparison Not Work with Floating Point Numbers?

0 Kudos
Message 4 of 4
(2,692 Views)