# NI TestStand

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Teststand MOD Function

"-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

Message 1 of 4
(194 Views)

## Re: Teststand MOD Function

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.

Message 2 of 4
(148 Views)
Solution
Accepted by topic author MattN76

## Re: Teststand MOD Function

"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.

Message 3 of 4
(128 Views)

## Re: Teststand MOD Function

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

Message 4 of 4
(124 Views)