MOD Operator Syntax

MOD Operator Syntax

brad.jackson
Enthusiast Enthusiast
1,636 Views
2 Replies
Message 1 of 3

MOD Operator Syntax

brad.jackson
Enthusiast
Enthusiast

Can anyone give me some examples of how to set up the syntax for the MOD Operator in iLogic?

 

As an example, I would hope to get the remainder of a length divided by a set value of 95".

120.4375" / 95" = 1.xxx-xxxxxxxx

I would like to know if and how I might use the MOD operator in the iLogic code to get the remainder rounded to the nearest 16th (which in this case should be 25.4375").

I have used the % in the parameters to accomplish this in the past, but I am not sure how to set it up in code.

0 Likes
Accepted solutions (1)
1,637 Views
2 Replies
Replies (2)
Message 2 of 3

J-Camper
Advisor
Advisor
Accepted solution

Here is a sample:

Dim inputVar As Double = 120.4375 in
Dim TOL As Double = 1 in  / 16 ul
Dim MODvalue As Double = 95 in

Dim Output1 As Double = Math.Round((inputVar Mod MODvalue) / TOL) * TOL

Logger.Trace(Output1)

 

 

0 Likes
Message 3 of 3

brad.jackson
Enthusiast
Enthusiast
Thank you very much
0 Likes