Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
mphekin12
Specialist
Specialist

Mod() Function

Can someone explain how mod(-4,3) returns a value of 2?

Thank

1 Solution

Accepted Solutions
Qrishna
Master
Master

I think it's working like the Excel function, and this function can be (according to Excel Help) evaluated like:

MOD(n, d) = n - d*INT(n/d)


So:

mod(-4,3) = -4 - 3*(-2) = +2


How this function works?

View solution in original post

5 Replies
robert_mika
Master III
Master III

When working with negative number we are looking for value larger  absolute value.

In this case -6 is larger than -4

and

-4=-6+2

mphekin12
Specialist
Specialist
Author

Robert,

Thanks for your reply but I am still not clear.  Where are you getting the -6 from?

robert_mika
Master III
Master III

Is the first number greater than 4 divided by 3.

Qrishna
Master
Master

I think it's working like the Excel function, and this function can be (according to Excel Help) evaluated like:

MOD(n, d) = n - d*INT(n/d)


So:

mod(-4,3) = -4 - 3*(-2) = +2


How this function works?

mphekin12
Specialist
Specialist
Author

Krishna,

Thanks for the explanation, now it makes sense!