05-10-2017 12:51 AM
Hi everyone,
I am working in a Labview project which has some structures, one of them is a while loop. In this loop I receive a numeric variable (4.25) and then subtract 0.25 until the result will be zero. The issue is that i've tried everything but still i can't do it. So your help will be greatly appreciated.
Thanks.
05-10-2017 01:06 AM - edited 05-10-2017 01:07 AM
You can do this with a shift register, a subtract node, and an equality node. However, be careful with equality, since you're using non-integer values. A test for (a-b)<small_amount will probably be more reliable than a-b=0.
Alternatively, subtract your 0.25 each time and check for less than zero. Just be aware this might stop an iteration later than what you want, so you'd need to handle that if so.
05-10-2017 01:09 AM
Hi pz,
and what's the relation to your thread topic? Is it a fault of the while loop?
The issue is that i've tried everything but still i can't do it.
What have you tried? What is "everything"?
(If it would be everything you would have found a solution to your problem!)
Because you didn't attach your VI I can only guess: the problem is related to floating point precision! Look up this topic in the forum, you will find a huge amount of related threads!
In this loop I receive a numeric variable (4.25) and then subtract 0.25 until the result will be zero
Possible solution:
05-10-2017 01:10 AM
Show us your code. Otherwise we can only guess what the problem might be.
My guess is that you are running into a limitation of the floating point format. Why don't you do everything 100x larger using integers, then divide the result by 100 for a DBL display.