Maisara-WD Posted July 27, 2008 Share Posted July 27, 2008 Hi guyspeace upon ucan u explain those operations for me??% Modulus (division remainder)++ Increment-- Decrement thanks Link to comment Share on other sites More sharing options...
Guest FirefoxRocks Posted July 27, 2008 Share Posted July 27, 2008 Hi guyspeace upon ucan u explain those operations for me??% Modulus (division remainder)++ Increment-- Decrement thanksIncrement - Adds 1If...i = 3;i++; then i would equal 4.Decrement - Subtracts 1 i = 3;i--; i would equal 2.i++ is the same as i = i+1;i-- is the same as i = i-1; Link to comment Share on other sites More sharing options...
jeffman Posted July 27, 2008 Share Posted July 27, 2008 % Any division operation can also be thought of as a fraction. Assuming integers for both the numerator and denominator, if you completely reduce the fraction (extracting the largest whole number value possible) there will or won't be a fractional portion less than zero that is "left over." If nothing is left over, % returns 0 or false. If a fractional part remains, % returns the numerator. This is especially useful in loops where you want to test if the iterating variable is a whole-number multiple or denominator of some value.Example: for i = 1 to 100. i % 10 returns false if i equals 10, 20, 30 etc.Example: for i = 1 to 100. i % 2 returns false if i is an even number, true if it's an odd numberFirefoxRocks has you covered on the others. Link to comment Share on other sites More sharing options...
Jesdisciple Posted July 27, 2008 Share Posted July 27, 2008 Example: for i = 1 to 100. i % 10 returns false if i equals 10, 20, 30 etc.Example: for i = 1 to 100. i % 2 returns false if i is an even number, true if it's an odd numberMaisara, keep in mind that 0 is evaluated as false and non-0 is evaluated as true.39 / 10 = 3 + (9 / 10)39 % 10 = 9 Link to comment Share on other sites More sharing options...
Kingy Posted July 28, 2008 Share Posted July 28, 2008 I know I've already posted this link in your other thread regarding operators but here we go again!I'm sure it will help you. http://www.w3schools.com/js/js_operators.asp Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.