Mod

Discussion in 'ASP General' started by RN1, Dec 14, 2007.

  1. RN1

    RN1 Guest

    79 Mod 92 evaluates to 79

    156 Mod 249 evaluates to 156

    So while using the Mod operator, if the first number is less than the
    second number, will the result be ALWAYS EQUAL to the first number?
     
    RN1, Dec 14, 2007
    #1
    1. Advertising

  2. RN1 wrote:
    > 79 Mod 92 evaluates to 79
    >
    > 156 Mod 249 evaluates to 156
    >
    > So while using the Mod operator, if the first number is less than the
    > second number, will the result be ALWAYS EQUAL to the first number?


    Yes. Think back to second or third grade when learning about division.
    If you divide 79 by 92, you got a remainder, right? 92 gazinto 79 zero
    times with a remainder of 79.
    That's the modulus, or mod for short.

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Dec 14, 2007
    #2
    1. Advertising

  3. "RN1" <> wrote in message
    news:...
    > 79 Mod 92 evaluates to 79
    >
    > 156 Mod 249 evaluates to 156
    >
    > So while using the Mod operator, if the first number is less than the
    > second number, will the result be ALWAYS EQUAL to the first number?


    Not exactly -390 is less than 79 but -390 mod 79 is 74.

    You might consider reading the documentation:-

    http://msdn2.microsoft.com/en-us/library/basszbdt.aspx


    Modulus is a standard mathematical operation:-


    http://mathworld.wolfram.com/Modulus.html



    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Dec 14, 2007
    #3
  4. "Anthony Jones" <> wrote in message
    news:...
    >
    > "RN1" <> wrote in message
    > news:...
    > > 79 Mod 92 evaluates to 79
    > >
    > > 156 Mod 249 evaluates to 156
    > >
    > > So while using the Mod operator, if the first number is less than the
    > > second number, will the result be ALWAYS EQUAL to the first number?

    >
    > Not exactly -390 is less than 79 but -390 mod 79 is 74.
    >


    Typo: -74

    > You might consider reading the documentation:-
    >
    > http://msdn2.microsoft.com/en-us/library/basszbdt.aspx
    >
    >
    > Modulus is a standard mathematical operation:-
    >
    >
    > http://mathworld.wolfram.com/Modulus.html
    >
    >
    >




    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Dec 14, 2007
    #4
  5. RN1

    RN1 Guest

    On Dec 15, 12:33 am, "Anthony Jones" <> wrote:
    > "RN1" <> wrote in message
    >
    > news:...
    >
    > > 79 Mod 92 evaluates to 79

    >
    > > 156 Mod 249 evaluates to 156

    >
    > > So while using the Mod operator, if the first number is less than the
    > > second number, will the result be ALWAYS EQUAL to the first number?

    >
    > Not exactly -390 is less than 79 but -390 mod 79 is 74.
    >
    > You might consider reading the documentation:-
    >
    > http://msdn2.microsoft.com/en-us/library/basszbdt.aspx
    >
    > Modulus is a standard mathematical operation:-
    >
    > http://mathworld.wolfram.com/Modulus.html
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET


    -19 Mod 7 evaluates to -5....that's fine but

    -19 Mod -7 also evaluates to -5. Why? Shouldn't it evaluate to 5?

    Also how does 19 Mod -7 evaluate to 5 (& not -5)?
     
    RN1, Dec 14, 2007
    #5
  6. RN1 wrote:
    > On Dec 15, 12:33 am, "Anthony Jones" <> wrote:
    >> "RN1" <> wrote in message
    >>
    >>

    news:...
    >>
    >>> 79 Mod 92 evaluates to 79

    >>
    >>> 156 Mod 249 evaluates to 156

    >>
    >>> So while using the Mod operator, if the first number is less than
    >>> the second number, will the result be ALWAYS EQUAL to the first
    >>> number?

    >>
    >> Not exactly -390 is less than 79 but -390 mod 79 is 74.
    >>
    >> You might consider reading the documentation:-
    >>
    >> http://msdn2.microsoft.com/en-us/library/basszbdt.aspx
    >>
    >> Modulus is a standard mathematical operation:-
    >>
    >> http://mathworld.wolfram.com/Modulus.html
    >>

    >
    > -19 Mod 7 evaluates to -5....that's fine but
    >
    > -19 Mod -7 also evaluates to -5. Why? Shouldn't it evaluate to 5?


    -7 * 2 = -14

    What do you have to add to -14 to get -19?

    >
    > Also how does 19 Mod -7 evaluate to 5 (& not -5)?


    Again, -7 * -2 = 14. What do you have to add to 14 to get 19?

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Dec 14, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. praveen

    MOD function synthesis

    praveen, Sep 23, 2003, in forum: VHDL
    Replies:
    1
    Views:
    887
    Allan Herriman
    Sep 24, 2003
  2. Kwaj

    Mod (%) Function in VHDL

    Kwaj, Jan 14, 2004, in forum: VHDL
    Replies:
    7
    Views:
    45,011
    jacky Renaux
    Jan 20, 2004
  3. Hari Sekhon
    Replies:
    0
    Views:
    559
    Hari Sekhon
    Jun 20, 2006
  4. ryles
    Replies:
    3
    Views:
    577
    Piet van Oostrum
    Jul 26, 2009
  5. T. Onoma
    Replies:
    9
    Views:
    395
    Dave Thomas
    Dec 15, 2003
Loading...

Share This Page