|
Re: Variable rollover with Labview (suggestions?)
I'm having a little trouble following exactly what you are trying to accomplish: could you provide example inputs and what you want as an output?
I've included a few options, all assume that rollover is 100.
Which of the following behaviors is correct?
1) 112 becomes 12
2) 112 becomes 100
Another interpretation: You have a variable x, and you are incrementing or decrementing by dx. You want output to "latch" to either extreme if you would otherwise roll.
x=98, dx=5, output = 100
x=98, dx=70, output = 100
x=3, dx=-5, output = 0
Perhaps pulling dx into your function would make it easier, as you can use it's sign without having to guess.
Also, would it help to temporarily use a 32bit int to avoid overflow, and then truncate back down?
|