I just bought book yesterday, and im stuck on what

Results 1 to 3 of 3

Thread: I just bought book yesterday, and im stuck on what

  1. #1
    DOWNER_0 Guest

    Default I just bought book yesterday, and im stuck on what

    Please explain this for me, what it means and what it does and how! Im only 15, so dont hurt me!! LOL!<BR>-----------------------------------------------<BR>Going along with integer division is the modulus operator. Whereas integer division returns the quotient when the two numbers are divided, modulus returns instead the remainder. For example:<BR>5 mod 3 returns 2<BR>4 mod 2 returns 0<BR>0 mod 8 returns 8<BR>1 mod 2 returns 1<BR>4 mod 2.2 returns 0<BR>8.3 mod 2.6 returns 2------<BR>dat is extracted from the book!<BR><BR>EXPLAIN! Thnx to anyone who replies!

  2. #2
    Join Date
    Dec 1969

    Default Your problem is you are too old...

    Your brother or sister in the 3rd or 4th grade could help you here! (Sorry...that&#039;s a bad joke. Trust me, many many adults don&#039;t get this one first time!)<BR><BR>Did you ever do long division and, instead of getting an answer which had a fractional part, write the answer as something like "17 Rem 5"??? Where "Rem" means "Remainder"?<BR><BR>That is, something like this:<BR><BR>&nbsp;&nbsp;&nbsp;17&nbsp;&nbsp;&nbsp ;rem 5<BR>&nbsp;&nbsp;_________________<BR>3&nbsp;&#12 4 56<BR>&nbsp;&nbsp;&nbsp; 51<BR>&nbsp;&nbsp;&nbsp;_____<BR>&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;5<BR><BR>???<BR><BR>Well, the MOD operator in VBScript has, as its *ONLY* purpose, the job of getting *just* the "Rem"ainder in a division operation. That&#039;s all.<BR><BR>So, using that same example:<BR><BR>&#060;%<BR>remainder = 56 Mod 3<BR>Response.Write remainder<BR>%&#062;<BR><BR>and the number 5 will be written on the display!<BR><BR>That&#039;s all there is too it.<BR><BR>Try all the examples you gave. Divide the first number by the second and see what the REMainder is. It will be the same as the MOD operator gives you.<BR><BR>Two of those examples *do* need explanation. <BR><BR>The MOD operator *ONLY* works with integers (whole numbers), so it always ROUNDS any non-integers you give it to the nearest integer.<BR><BR>So:<BR><BR>4 MOD 2.2 *becomes* 4 MOD 2 (and since 2 divides evenly into 4, the remainder is zero)<BR><BR>8.3 MOD 2.6 *becomes* 8 MOD 3 (2.6 rounded is 3, and 8 divided by 3 is 2 Remainder 2, right? So...)<BR><BR>Hokay?<BR><BR><BR><BR>

  3. #3
    DOWNER_O Guest

    Default RE: Your problem is you are too old...

    Bill, you&#039;re the king, it worked!<BR>Simple as it was, I never attended school, no wonder!<BR>I owe you dinner for helping me on this!<BR>Let me know when/where...LOL just kidding.<BR>Thankx again!!<BR><BR>

Posting Permissions

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