view · edit · sidebar · attach · print · history

Remainder Operator

<< Proc | Index | RegularExpression >>

 x%

is called 'remainder operator', which calculates 'residual number' by division. For example,

 10%3 becomes 1, because 3 x 3 + '1' =10
 5%3 becomes 2, because 3 x 1 + '2' = 5
 7%2 becomes 1, because 2 x 3 + '1' = 7

Generally, 'x%2==0' is used to take 'even number'.

view · edit · sidebar · attach · print · history
Page last modified on March 15, 2011, at 09:06 AM