NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Teststand MOD Function

Solved!
Go to solution

"-10 MOD 100" 

 

Should return 90

 

Teststand returns -10 when asked to do "-10 MOD 100"

 

Can anyone shed any light as to why or if there is anyway around this

 

Many Thanks

 

0 Kudos
Message 1 of 4
(180 Views)

Bumping this, I need an answer, I've worked around it calling out to a method in some code but I want to do it within Teststand if it's possible. 

0 Kudos
Message 2 of 4
(134 Views)
Solution
Accepted by topic author MattN76

"If the dividend or divisor is negative, then two possible choices for the remainder occur. In mathematics, the remainder is positive, but implementations in programming languages differ."

 

So, modulo division can be truncated or floored when implemented in a programming language. Based on the fact that the expression produced a negative remainder would indicate that TestStand has chosen to use truncated modulo division.

 

Reference: Modulo Operations with Negative Numbers (omnicalculator.com)

Message 3 of 4
(114 Views)

Thankyou, that's very helpful, everyday is a school day

0 Kudos
Message 4 of 4
(110 Views)