Results 1 to 11 of 11

Thread: mod keyword?

  1. #1
    Join Date
    Nov 2007
    Location
    Nowhereville
    Posts
    1,155
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default mod keyword?

    I see mod as a keyword in math functions and I was wondering what that was?
    Formerly known as Cut em2 it

  2. #2
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    It's short for modulus. It's just like dividing, but it returns the remainder instead. For example, 5 mod 3 would be 2.

  3. #3
    Join Date
    Jul 2007
    Posts
    1,055
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes like he said it just means the remainder of division. 5 mod 3 = 2 would be a correct statment.

  4. #4
    Join Date
    Oct 2006
    Location
    finland, helsinki
    Posts
    2,501
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    People often use it like this:

    SCAR Code:
    If(CurrentLoads Mod HowManyLoads = 0)Then
      NextPlayer(TRUE/False);

    Etc..

    Code:
    • Narcle: I recall Jukka releasing a bunch of scripts like this before... Its how he rolls I think. rofl
    • Solarwind: Dude, you are like... t3h s3x.
    • Hy71194: JuKKa you're a machine! You released 3 scripts in 10 minutes! :O
    • benjaa: woah.... Jukka is the man Guildminer pwns all
    • NaumanAkhlaQ: And JuKKa Is my Her0!

  5. #5
    Join Date
    Aug 2007
    Posts
    1,404
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    NumberX mod NumberY
    The result of that is calculated this way:
    SCAR Code:
    NumberX-(NumberY*(NumberX/NumberY))

    Very simply, even though it might look a little confusing.

    -Knives

  6. #6
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    That formula can't be right, KoK. NumberY * (NumberX / NumberY) will always give you NumberX again. You'll always get 0 using that formula, so I assume something's wrong.

    EDIT: My bad, I thought you were Timer for some reason.
    :-)

  7. #7
    Join Date
    Aug 2007
    Posts
    1,404
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Who are you calling "Timer" ?
    Weirdly, my formula works correct. I understand how you can see a problem, but it gives the right answers to me. Maybe I need to test it a little more.

    -Knives

  8. #8
    Join Date
    Jul 2007
    Location
    St. Louis, Missouri, USA.
    Posts
    575
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by King of Knives View Post
    Who are you calling "Timer" ?
    [spam] Lol. [/spam]
    -You can call me Mick-



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

    Default

    basically broken down it takes first input divided by the second one and returns the remainder. Useful for doing things like every three times
    SCAR Code:
    if i mod 3 = 0 then

  10. #10
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Method View Post
    That formula can't be right, KoK. NumberY * (NumberX / NumberY) will always give you NumberX again. You'll always get 0 using that formula, so I assume something's wrong.

    EDIT: My bad, I thought you were Timer for some reason.
    It works because, when diving an integer by another integer, the quotient is always floored

  11. #11
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    Okay, that makes a lot more sense. I just figured it wasn't rounded, but I guess it is. Thanks for clearing that up.
    :-)

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Search keyword 3+ chars.
    By Negaal in forum SRL Site Discussion
    Replies: 1
    Last Post: 04-03-2008, 12:57 PM

Posting Permissions

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