Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Oct 2012
    Location
    Italy
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts

    How to make the rest entire?

    Hi all guy!! I have problem begginer!!
    In my equazion random ex: 140/26 = 5 rest 10.
    How to do make my rest 10 and put in an a Variable? (in Javascript)?
    Code:
    function rest ()
    {
    var a = 140;
    var b = 26;
    var division = a / b; // 140 / 26 = 5 rest 10 :D
    alert (division);

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,316
    Thanks
    23
    Thanked 613 Times in 612 Posts
    Code:
    <script type="text/javascript">
    	var a = 140;
    	var b = 26;
    	var division = Math.floor(a/b);
    	var reminder = a%b;
    	alert(division+" with a remember of "+reminder);
    </script>

  • #3
    New Coder
    Join Date
    Oct 2012
    Location
    Italy
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    Code:
    <script type="text/javascript">
    	var a = 140;
    	var b = 26;
    	var division = Math.floor(a/b);
    	var reminder = a%b;
    	alert(division+" with a remember of "+reminder);
    </script>
    Ei ! i'm test your code but the rest or remember isn't correct, i write 131 / 26
    = 5 and rest 0, the code back me rest remember 1 ...
    Can you explain me how to do the 1%b Thanks guy for your time!!

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by triko View Post
    Ei ! i'm test your code but the rest or remember isn't correct, i write 131 / 26
    = 5 and rest 0, the code back me rest remember 1 ...
    Can you explain me how to do the 1%b Thanks guy for your time!!
    Well, that is the correct answer!


    Code:
    <script type="text/javascript">
    var a = 131;
    var b = 26;
    var division = Math.floor(a/b);
    var remainder = a%b;
    alert (division+" with a remainder of "+remainder); // 5 with a remainder of 1
    </script>
    Your English seems rather fractured. The word is remainder, not reminder or remember.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,435 Times in 4,400 Posts
    Actually, it was Sunfighter who used "remember" and "reminder" instead of "remainder".

    Not sure they teach English in Missouri. <grin/>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,316
    Thanks
    23
    Thanked 613 Times in 612 Posts
    hee hee, Guess it was.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,435 Times in 4,400 Posts
    Hey, this is the JavaScript forum, not the English forum. You got the important part right. <grin/>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    New Coder
    Join Date
    Oct 2012
    Location
    Italy
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Well, that is the correct answer!


    Code:
    <script type="text/javascript">
    var a = 131;
    var b = 26;
    var division = Math.floor(a/b);
    var remainder = a%b;
    alert (division+" with a remainder of "+remainder); // 5 with a remainder of 1
    </script>
    Your English seems rather fractured. The word is remainder, not reminder or remember.
    No Philip I had copy the word by code of sunfighter!!!!
    But, don't understand what is a%b

  • #9
    New Coder
    Join Date
    Oct 2012
    Location
    Italy
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Hey, this is the JavaScript forum, not the English forum. You got the important part right. <grin/>
    Thanks Pedant for clarification But, however the English it's more important for make oneself understood Infact my English , it's a little crap!!! no, more crap

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,435 Times in 4,400 Posts
    a % b means *EXACTLY* "calculate the remainder when a is divided by b".

    % is properly called the "modulo operator". What you called "rest" and we call "remainder" are both NOT correct mathematical terminology. "Modulo" is the correct terminology and % is indeed the modulo operator.

    Incidentally, many languages use % as the modulo operator:
    JavaScript
    Java
    C
    C++
    C#
    PHP
    and more.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    New Coder
    Join Date
    Oct 2012
    Location
    Italy
    Posts
    72
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    a % b means *EXACTLY* "calculate the remainder when a is divided by b".

    % is properly called the "modulo operator". What you called "rest" and we call "remainder" are both NOT correct mathematical terminology. "Modulo" is the correct terminology and % is indeed the modulo operator.

    Incidentally, many languages use % as the modulo operator:
    JavaScript
    Java
    C
    C++
    C#
    PHP
    and more.
    An ok, so the name correct it's Modulo OK... however I had called "rest" because in Italian remainder is resto!


  •  

    Posting Permissions

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