Signed word lengths and indexes
Adam Ruppe
destructionator at gmail.com
Tue Jun 15 06:25:27 PDT 2010
On 6/15/10, Pelle <pelle.mansson at gmail.com> wrote:
> for (uint i = end - 1; i < uint.max; --i)
>
> Same functionality, really clever.
That's wrong rather than clever though.
for(i < length) is saying "continue as long as you are inside the
array's bounds", which is exactly what you mean in that loop. The only
"tricky" is the understanding that an array index is never negative,
but this shouldn't require extra thought in the first place.
More information about the Digitalmars-d
mailing list