×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
On Tue, 3 Feb 2009, Simon Coulter wrote:
generally 0-based. However, in all programming languages (at least
that I can think of), on for-loop termination, the index of the loop
is always 1 greater than the terminal value--regardless of the
starting value.
Not necessarily true, depending on how you think of "termination value".
In many languages, a common construct for for loops is the following:
for (i=0; i<10; i++)
In this case the loop terminates when i reaches a value of ten, i.e. equal
to the termination value. Contrast the above to this:
for (i=1; i<=10; i++)
The above construct is common in RPG using the DO and FOR opcodes. In
this case i does reach a value which is one greater than the termination
value of ten.
Of course none of the above matters either way if you are coding a for
loop using an index that cannot fit the test required. If you use an
index that is 4,0 and your test is i < 10000 then it will never work
because you're index cannot ever get to your termination value of 10000.
The case is similar for i <= 9999. In my opinion, the first way of coding
(i.e. the "C way") is more clear that your index needs to be large enough
to reach the termination value. I think seeing "10000" makes the size
requirement jump off the page more than "9999".
James Rich
if you want to understand why that is, there are many good books on
the design of operating systems. please pass them along to redmond
when you're done reading them :)
- Paul Davis on ardour-dev
As an Amazon Associate we earn from qualifying purchases.