Share via

Excel Function - MOD

Anonymous
2022-07-10T05:53:41+00:00

Please explain, Why the MOD output is not the Remainder as it claims in its Function Description.

1 is OK( I can understand ), but Why 0.6? (as per mathematics rule it should be 1.4 or 0.4.)

Please explain step by step Mathematically.

Maths Rule : <br><br>Remainder = Dividend - Divisor x Quotient
Number Divisor MOD Output QUOTIENT Remainder as per Mathematics Rule ↑
23 2 1 11 1
-23 2 1 -11 -1
-23.4 2 0.6 -11 -1.4
-23.4 1 0.6 -23 -0.4
23.4 2 1.4 11 1.4
23.4 1 0.4 23 0.4

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Anonymous
    2022-07-10T13:07:37+00:00

    in short, "Mod function description given by Microsoft in Help section is wrong." Am I write?

    No, "write" is wrong. (ha ha)

    As I said, the description is incomplete, not wrong. And as I demonstrated with the wikipage, it is the traditional way to describe mod(ulo).

    IMHO, the MOD help page redeems itself with examples that clarify its full meaning for negative parameters. That is more than some MSFT help pages do.

    But you might appreciate this statement from a MSFT doc page for the .Net VB (*) mod operator (click here): There is a difference between *remainder* and *modulus* in mathematics, with different results for negative numbers.

    So arguably, a more precise way to describe the Excel MOD function is: it returns the (mathematical) modulus, which differs from the (arithmetic) remainder when only one parameter is negative.


    (*) There is a world of difference between .Net VB and Excel VBA mod operators with respect to data type support. The Excel VBA mod operator is explained elsewhere (click here).

    2 people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Anonymous
    2022-07-10T10:13:46+00:00

    My question is Why MOD description claims that It return Remainder?

    That was not your entire question. You also wrote: Please explain step by step **Mathematically**. I addressed that part.

    As to the (in)accuracy of the MSFT documentation, this is a peer-to-peer user forum, and none of us has any insight into why MSFT does what it does. With Unix (another O/S), we used to say never ask why; it is what it is.

    That said, the following are my opinions, FWIW.

    First, MOD(n,d) does indeed return the (integer) remainder of the division n/d when n and d are both positive integers.

    We find a similar description in the wikipage (https://en.wikipedia.org/wiki/Modulo_operation), to wit: the modulo operation returns the remainder or signed remainder of a division.

    And in fact, the VBA mod operator is limited to integers.

    So the MSFT (and wiki) description is merely incomplete.

    Second, IMHO, it is not uncommon for MSFT documentation to be incomplete, if not entirely incorrect. So I always take MSFT documentation with a grain of salt.

    Third, the second point has become (and is becoming) increasingly worse with each new version of Excel. MSFT seems to be on a mission to "dumb down" their documentation, even at the expense of correctness and completeness.

    And MSFT is not alone in that regard. It is a "virus" that has spread throughout the computer industry. I started noticing the change in the late-1970s. And of course, many companies do not even provide technical documentation anymore.

    "A word to the wise...."


    PS.... Returning to the mathematical explanation, to wit: MOD(n,d) = n - d*INT(n/d). We can find that definition in Knuth, among others. But not everyone agrees with that definition. In VBA, the definition of the mod operator seems to be: n mod d = n - d*TRUNC(n/d). The TRUNC function truncates negative results toward zero.

    1 person found this answer helpful.
    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-07-10T11:47:06+00:00

    Thanks joeu2004, for detailed answer.

    in short, "Mod function description given by Microsoft in Help section is wrong."

    Am I right?

    0 comments No comments
  2. Anonymous
    2022-07-10T07:28:16+00:00

    Thanks joeu2004,

    My question is Why MOD description claims that It return Remainder?

    0 comments No comments
  3. Anonymous
    2022-07-10T06:26:30+00:00

    MOD(n,d) is defined mathematically as n - d*INT(n/d) .

    INT is defined as the largest integer less than or equal to its parameter.

    For positive numbers, INT truncates toward zero.

    For negative numbers, INT truncates away from zero.

    In other words, values to the left are always less, for both positive and negative numbers.

    For MOD(-23.4, 2), we calculate -23.4 - 2*INT(-23.4/2).

    -23.4/2 = -11.7; and INT(-11.7) = -12, not -11 as you might think. Note the =-12<-11.7 returns TRUE.

    So we calculate -23.4 - 2*(-12) = -23.4 + 24 = -23.4 + 24 = 0.6.

    Likewise, MOD(-23.4, 1) = -23.4 - 1*INT(-23.4/1) = -23.4 - 1*(-24) = -23.4 + 24 = 0.6.

    0 comments No comments