Results 1 to 21 of 21

Thread: c ++ MODULUS OPERATOR

  1. #1
    Fleet Admiral
    Join Date
    Oct 2000
    Location
    In a nutshell
    Posts
    9,678

    c ++ MODULUS OPERATOR

    what do I do now!
    Last edited by oblongmelon; 05-11-2008 at 08:22 PM.

  2. #2
    hot in velour pants Burzhui's Avatar
    Join Date
    Jun 2000
    Location
    New York City
    Posts
    9,200
    the modulus operator gives you the remainder, such as 15%6=3

    6 goes into 15 2 times and 3 is left over
    ____________________
    IF A FAT GIRL FALLS IN THE WOODS
    DO THE TREES LAUGH?

  3. #3
    Fleet Admiral
    Join Date
    Oct 2000
    Location
    In a nutshell
    Posts
    9,678
    bless you.

  4. #4
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874
    Are you wondering about the workings of a modulus operator in general, or something specific to c++? In general, a modulus operator works like this:

    Divides the value of one expression by the value of another, and returns the remainder.

    result = number1 % number2

    where % is the modulus operator.

    For example,

    20 % 8 would return a value of 4
    stay low... keep moving...

  5. #5
    hot in velour pants Burzhui's Avatar
    Join Date
    Jun 2000
    Location
    New York City
    Posts
    9,200
    Originally posted by Markel
    Are you wondering about the workings of a modulus operator in general, or something specific to c++? In general, a modulus operator works like this:

    Divides the value of one expression by the value of another, and returns the remainder.

    result = number1 % number2

    where % is the modulus operator.

    For example,

    20 % 8 would return a value of 4
    wow dude i beat you by 4 minutes

    and no prob oblongmelon
    ____________________
    IF A FAT GIRL FALLS IN THE WOODS
    DO THE TREES LAUGH?

  6. #6
    Fleet Admiral
    Join Date
    Oct 2000
    Location
    In a nutshell
    Posts
    9,678
    Thanks guys I appreciate it..(and so does Becca)

  7. #7
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874
    Originally posted by Burzhui


    wow dude i beat you by 4 minutes
    I got distracted while I was typing my response.

    But I think mine was better.
    stay low... keep moving...

  8. #8
    hot in velour pants Burzhui's Avatar
    Join Date
    Jun 2000
    Location
    New York City
    Posts
    9,200
    Originally posted by Markel

    I got distracted while I was typing my response.

    But I think mine was better.
    dude you kidding right, mine was right and straight to the point
    ____________________
    IF A FAT GIRL FALLS IN THE WOODS
    DO THE TREES LAUGH?

  9. #9
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874
    Originally posted by Burzhui


    dude you kidding right, mine was right and straight to the point
    Ever try to code:
    15%6=varname

    That's one reason why I think my answer was better.
    stay low... keep moving...

  10. #10
    hot in velour pants Burzhui's Avatar
    Join Date
    Jun 2000
    Location
    New York City
    Posts
    9,200
    Originally posted by Markel

    Ever try to code:
    15%6=varname

    That's one reason why I think my answer was better.
    you mean varname = 15 % 6;

    I gave it in words and an example... boo ya grandma
    ____________________
    IF A FAT GIRL FALLS IN THE WOODS
    DO THE TREES LAUGH?

  11. #11
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874
    Originally posted by Burzhui

    you mean varname = 15 %6;
    Look at your first response, and tell me what order you put it in!
    stay low... keep moving...

  12. #12
    hot in velour pants Burzhui's Avatar
    Join Date
    Jun 2000
    Location
    New York City
    Posts
    9,200
    that was theory man

    in mathematics 15%6=3

    in programming

    int result;
    result = 0;
    result = 15 % 6;

    return result;
    ____________________
    IF A FAT GIRL FALLS IN THE WOODS
    DO THE TREES LAUGH?

  13. #13
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874
    Originally posted by Burzhui
    that was theory man
    Clarity is what it's all about, man. That's why I gave a CLEAR explanation.
    stay low... keep moving...

  14. #14
    hot in velour pants Burzhui's Avatar
    Join Date
    Jun 2000
    Location
    New York City
    Posts
    9,200
    hey read the reply after mine... my explanation was understood...

    wanna duel???
    ____________________
    IF A FAT GIRL FALLS IN THE WOODS
    DO THE TREES LAUGH?

  15. #15
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874


    I won.
    stay low... keep moving...

  16. #16
    hot in velour pants Burzhui's Avatar
    Join Date
    Jun 2000
    Location
    New York City
    Posts
    9,200
    Originally posted by Markel


    I won.
    you missed plus in a ny case i'm a porn making and here you go and to finish you off
    ____________________
    IF A FAT GIRL FALLS IN THE WOODS
    DO THE TREES LAUGH?

  17. #17
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874
    Originally posted by Burzhui
    you missed plus in a ny case i'm a porn making and here you go and to finish you off
    That's lame. Just admit it - I'm better.
    stay low... keep moving...

  18. #18
    hot in velour pants Burzhui's Avatar
    Join Date
    Jun 2000
    Location
    New York City
    Posts
    9,200
    Originally posted by Markel

    That's lame. Just admit it - I'm better.
    uhhh Cha

    i answered first and it was good and understandable... but your input is obviously valuable as well, so shake on it, and move on.
    ____________________
    IF A FAT GIRL FALLS IN THE WOODS
    DO THE TREES LAUGH?

  19. #19
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874
    Ok. You can go back to your "weekend interests".
    stay low... keep moving...

  20. #20
    Ruler-Of-All-Things-Beer BrewMaster's Avatar
    Join Date
    Dec 2000
    Location
    Pasadena, CA
    Posts
    10,249
    Haha. this useless exchange was pretty funny to read.

  21. #21
    Chief of Naval Operations Markel's Avatar
    Join Date
    Feb 2001
    Posts
    11,874
    Originally posted by BrewMaster
    Haha. this useless exchange was pretty funny to read.
    Well, I was going to let this thread drop off the bottom, but as long as you "woke it up", I'll add one more thing. There was a reason that I "pressed" this issue. It is true that Burzhui's answer was adequate to meet the need. However, as an answer to a programming language question, it was weak as compared to what followed. I have been writing software for 30 years now, and believe me, I have learned the value of code that is carefully planned out AND DOCUMENTED as compared to something that is just slammed together and happens to work. The first takes a little longer up front, but in the end it usually saves time, and in the long run (for maintainability) it is infinitely better.

    So, if you are in pursuit of a career dealing with software development, take a lesson from someone who's been there.
    stay low... keep moving...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •