Results 1 to 6 of 6

Thread: How Do You Mod?

  1. #1
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default How Do You Mod?

    Simba Code:
    If Tries > 0 And
           ((Tries Mod 5) = 0) Then LastStep;

    How do you mod?
    <3
    Easy question, but it made for a good thread title hauh?!

  2. #2
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    Simba Code:
    writeln(12 mod 5);

    edit: it seems like ur doin it right in your code
    edit2:

    Simba Code:
    {insert big number}  mod  {insert small number}
    Last edited by x[Warrior]x3500; 03-05-2013 at 10:54 PM.

  3. #3
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    My Tries is being inced, so at first it's smaller.
    I guess I should do If Tries > 5 then If Tries Mod 5=0 then?
    except properly?

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Works like a charm:
    Simba Code:
    program new;

    Var
      Tries: Integer;

    begin
      Tries := 0;

      repeat
        writeln(Tries);
        If ((Tries > 0) And (Tries Mod 5 = 0)) Then
          writeln('laststep');

        Inc(Tries);
      until(Tries = 50);
    end.
    Working on: Tithe Farmer

  5. #5
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Yeah it was just weird random stuff going wrong.
    Dem extra (((())((()()((()(s never hurt, thanks guys
    Simba Code:
    If ((Tries > 0) And (Tries Mod 5 = 0)) Then LastStep;

    Repped you masterBB for this and my last help thread, enjoy your extra square!

  6. #6
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Yeah it was just weird random stuff going wrong.
    Dem extra (((())((()()((()(s never hurt, thanks guys
    Simba Code:
    If ((Tries > 0) And (Tries Mod 5 = 0)) Then LastStep;

    Repped you masterBB for this and my last help thread, enjoy your extra square!
    Thanks, well for your reputation power I guess I can give an explanation why too. ^^

    In pascalscript there is a certain order of calculating equations with different mathematical operators. It doesn't matter in which order you type it, it will just go through this order. An example would be:

    10 + 5 * 5


    Where you can clearly see that multiplying is done before adding. This of course equals what you learned at elementary school with Math. Now, it gets interesting when you use mathematical operators you haven't heard of at school. Shr, Shl and Mod are examples. What you might not know is that And is also one of these operators. It is a Bitwise operator, it basically checks for what bits are both 1's.

    example:

    10 < 19 and (10 mod 8) = 2


    The problem is this. The first thing it will do are the parentheses. So you will get:

    10 < 19 and 2 = 2


    The next step will be the And operator since bitwise operators are very high on the list of Mathematical operators. Much higher then < and =, these are actually pretty low on the list. So the next step will be:

    10 < 2 = 2


    Now this will give an error in pascalscript, and unexpected results in lape.

    Want to know more about bitwise operators? Yakman(there are also some others) wrote a tut about it: http://villavu.com/forum/showthread.php?t=18514
    Last edited by masterBB; 03-06-2013 at 12:14 AM. Reason: grammar :O
    Working on: Tithe Farmer

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
  •