
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!

Your problem is you are too old...
Your brother or sister in the 3rd or 4th grade could help you here! (Sorry...that's a bad joke. Trust me, many many adults don'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> 17   ;rem 5<BR> _________________<BR>3  4 56<BR> 51<BR> _____<BR>   ; 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's all.<BR><BR>So, using that same example:<BR><BR><%<BR>remainder = 56 Mod 3<BR>Response.Write remainder<BR>%><BR><BR>and the number 5 will be written on the display!<BR><BR>That'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 nonintegers 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>

RE: Your problem is you are too old...
Bill, you'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

Forum Rules

