[thelist] ASP - if x = every nth?

Phil Turmel pturmel-webdev at turmel.org
Wed Jun 6 16:17:26 CDT 2007


Matt Warden wrote:
> On 6/6/07, Phil Turmel <pturmel-webdev at turmel.org> wrote:
> 
>>>if (i - 4) mod 5 = 0 then
>>>
>>
>>Jon,
>>
>>For readability when the offset is a constant, I'd move the
>>offset to the right of the equals, like so:
>>
>>if i mod 5 = 4 then
> 
> 
> The formulation I offered was because of readability. The option above
> does not represent the offset and requires a deeper understanding of
> the modulus operator. I rarely use this operator, so I would have to
> actually work it out to see if it would work... which is why I suspect
> you offered your evidence:
> 
> 
>>0,5,10,15,... "if i mod 5 = 0 then"
>>1,6,11,16,... "if i mod 5 = 1 then"
>>2,7,12,17,... "if i mod 5 = 2 then"
>>3,8,13,18,... "if i mod 5 = 3 then"
>>4,9,14,19,... "if i mod 5 = 4 then"
> 
Matt,

Hmm.  'Subtract, modulus, + equivalence' is more readable than
'modulus + equivalence'.  I respectfully disagree.  And I think
the same level of understanding of modulus is required to use
either form.

Indeed, I offered the evidence as an example to help others
understand the modulus operator.  The OP, in asking about the
series "4,9,14,19...", showed that an explanation was in order.

Phil




More information about the thelist mailing list