note 38945 deleted from language.expressions by nlopess
| From: | nlopess@php.net | Date: | Tue, 13 Jan 2004 14:54:07 +0000 |
| Subject: | note 38945 deleted from language.expressions by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-63440@lists.php.net to get a copy of this message | ||
Note Submitter: dchris1@bigpond.net.au
----
In response to the comment posted by 'Miki' below, the % operator is indeed a C / C++
style modulus operator. However, Ruben Bonke's comment was also correct - Modulus can be
determined by repeatedly subtracting an integer number from another integer until it reaches a value
is between 0 and the value you're subtracting. So, for example, in the case of 23 % 5, the
result will be 3:
23 - 5 = 18 (not between 5 and 0, so continue)
18 - 5 = 13 (not between 5 and 0, so continue)
13 - 5 = 8 (not between 5 and 0, so continue)
8 - 5 = 3 (less than 5 and greater than 0, so stop)
This is probably the simplest way to determine a modulus, and I believe it's the method that
most computer processors use in hardware.