NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Modulus in a If Condition

Solved!
Go to solution

Hello,

 

i have some problems with the Modulus Operator in an If condition:

 

The function of the if branch should be processed every few seconds (parameter.interval).

 

For example, every 10 seconds for <-> if(TimeDelta % 10 ==0). <->

 

The TimeDelta counts the seconds for the function to be executed.

 

I would be grateful for any help

Code_Salad_0-1635845696468.png

Code_Salad_1-1635845732118.pngCode_Salad_2-1635845791778.png

 

 

0 Kudos
Message 1 of 4
(1,116 Views)
Solution
Accepted by topic author Code_Salad

OK, I found the solution myself.

The seconds() command returns a floating point number, I thought that by defining the associated variable as INT and storing the value in it, I would have an integer. To the best of my knowledge, this is not the case.

I have solved the problem by using the round function and rounding to the nearest integer, so I get whole residual numbers and my Modulu operator works.

But it would still be worth knowing why the variables that are created as INT (and also displayed as such, without a comma value!) are nevertheless stored internally(?) as floating point numbers.

 

Cheers

 

P.SI found the solution myself by passing the variables into LabView and there it was immediately apparent that they were floating point numbers after all.

0 Kudos
Message 2 of 4
(1,101 Views)

@Code_Salad wrote:

But it would still be worth knowing why the variables that are created as INT (and also displayed as such, without a comma value!) are nevertheless stored internally(?) as floating point numbers.


Just because you display the values as an integer (no decimal places) does not mean they are stored as integers.  As far as I am aware, all numerics in TestStand are floating point values.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 4
(1,093 Views)

You can create integer numeric variables. Create a number and then right click on it and choose from the Representation submenu.

0 Kudos
Message 4 of 4
(1,077 Views)