Results 1 to 5 of 5

Thread: Mod

  1. #1
    Join Date
    May 2007
    Location
    baltimore, md
    Posts
    836
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default Mod

    ok when you use the mathematical function mod is this what it does
    it takes the first number and calculates how far away from the closes multiple of the last number.

    for example
    SCAR Code:
    4 mod 6
    this would be 1 because 4 is one away from the closest multiple of 6 which is 3


    i dont know if this is correct but it seems the most logical.

  2. #2
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by jhildy View Post
    ok when you use the mathematical function mod is this what it does
    it takes the first number and calculates how far away from the closes multiple of the last number.

    for example
    SCAR Code:
    4 mod 6
    this would be 1 because 4 is one away from the closest multiple of 6 which is 3


    i dont know if this is correct but it seems the most logical.
    Nope, here is what the mod function does.

    It takes the first number, divedes it by the second, and return the remainder.

    for example, 4 mod 6 means
    4 divided by 6, = 0, with a remainder of 4
    so the answer is 4

    another?
    8 mod 2
    8 divided by 2 is 4, with a remainder of 0
    so the answer is 0

    I normaly use mods when I have a repeat, but I want to do something every X times it repeats.

    Check this out
    SCAR Code:
    program New;
    var repeats:Integer;
    const howOften=4;
    begin
      repeats:=0;
      repeat
        writeln(inttostr(repeats)+' mod ' + inttostr(howOften) + ' is ' + inttostr((repeats mod howOften)));
        if ((repeats mod howOften)=0) then //the "0" could be any number, depending on when u want the first true
          writeln('Time for a special thing to happen!!');
        repeats:=repeats+1;
      until(repeats>15);
    end.




    0 mod 4 is 0
    Time for a special thing to happen!!
    1 mod 4 is 1
    2 mod 4 is 2
    3 mod 4 is 3
    4 mod 4 is 0
    Time for a special thing to happen!!
    5 mod 4 is 1
    6 mod 4 is 2
    7 mod 4 is 3
    8 mod 4 is 0
    Time for a special thing to happen!!
    9 mod 4 is 1
    10 mod 4 is 2
    11 mod 4 is 3
    12 mod 4 is 0
    Time for a special thing to happen!!
    13 mod 4 is 1
    14 mod 4 is 2
    15 mod 4 is 3
    Successfully executed
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  3. #3
    Join Date
    May 2007
    Location
    baltimore, md
    Posts
    836
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    ok my way made sense but your right that is the correct thing.

  4. #4
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by jhildy View Post
    ok my way made sense but your right that is the correct thing.
    You way made sense, but it was not right.
    4 mod 6 is NOT 1, as you said...
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  5. #5
    Join Date
    Jun 2007
    Location
    I'm not sure...
    Posts
    581
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by lordgreggreg View Post
    You way made sense, but it was not right.
    4 mod 6 is NOT 1, as you said...
    Can you say "Pwnt"?
    ---------------------------------------------------------


    Pm me if you need any math functions made. Me = l0ving t3h mathz

    ---------------------------------------------------------

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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