There's one important use case for Dijkstra's alternative (c), that is, an interval closed at both ends. That is when your set has a maximum element and you want to be able to express an interval including the maximum. This is, of course, important in any programming language whose basic integer types have a bounded range. For instance, the following loop in C never halts: for(uint8_t i = 0; i What's even worse, the…
I don't quite understand what you're saying. If you change the code to for(uint8_t i = 0; i then it still doesn't halt.
Why numbering should start at zero (1982)
51–60 of 72 posts
Re: Why numbering should start at zero (1982)
#52Re: Why numbering should start at zero (1982)
#53The initial sentence has always bothered me > To denote the subsequence of natural numbers 2, 3, ..., 12 without the pernicious three dots What's so pernicious about them? I don't see it. It seems like a clear and intuitive way to communicate a sequence to me. I even wrote a little range generator in JS to explore parsing declarations like that. https://github.com/chrisbroski/iterize It seems to work fine.
Re: Why numbering should start at zero (1982)
#54E.g. if you divide a matrix of 100 columns into 20 vertical bands of width 5 each.
Mathematicians use 1-based indexing for both the element index and the band index, so there band n would start at coordinate "(n - 1) * 100 / 20 + 1"
For a programmer, band n would start at "n * 100 / 20"
That's two correction terms that you need to add in math which programmers don't!
I had to use Matlab for microphone arrays once and it was full of + 1's and - 1's everywhere due to that.
Another example of mathematics and off by one errors: a polynomial. They call it "degree n" if the highest power is n, except I see n+1 coefficients in there and need to allocate an n+1 sized array to contain its coefficients, so why not call its degree the amount of terms, including the "x^0" one. The powers themselves in the polynomial are already hinting at 0-based indexing in this case.
Mathematicians, please use coordinate "0,0" for the top left element of a matrix :)
Re: Why numbering should start at zero (1982)
#55Programmers seem in general to know that 0-based works best, but mathematicians (and mathematical and statistical programming languages) seem to prefer 1-based, and I don't understand why that is? Isn't mathematics also easier with 0-based? E.g. if you divide a matrix of 100 columns into 20 vertical bands of width 5 each. Mathematicians use 1-based indexing for both the element index and the band index, so there band…
Re: Why numbering should start at zero (1982)
#56Re: Why numbering should start at zero (1982)
#57So random question because I know I would get this wrong in an interview, but would a 0 based indexing system have fewer assembly language instructions to calculate a memory offset than a 1 based system?
There might be some other tricks you can play depending on your instruction set, but nothing comes to mind.
Re: Why numbering should start at zero (1982)
#58Programmers seem in general to know that 0-based works best, but mathematicians (and mathematical and statistical programming languages) seem to prefer 1-based, and I don't understand why that is? Isn't mathematics also easier with 0-based? E.g. if you divide a matrix of 100 columns into 20 vertical bands of width 5 each. Mathematicians use 1-based indexing for both the element index and the band index, so there band…
Re: Why numbering should start at zero (1982)
#59Programmers seem in general to know that 0-based works best, but mathematicians (and mathematical and statistical programming languages) seem to prefer 1-based, and I don't understand why that is? Isn't mathematics also easier with 0-based? E.g. if you divide a matrix of 100 columns into 20 vertical bands of width 5 each. Mathematicians use 1-based indexing for both the element index and the band index, so there band…
Interesting that you mention polynomials, as the constant term in them is gennerally given the subscript 0. In fact, it sounds like you want some form of 1 based indexing, where constant polynomials are degree 1, linear degree 2, etc.
an array with elements at index 0,1,2,3 has size 4
Re: Why numbering should start at zero (1982)
#60Earlier quoted context omitted.
Interesting that you mention polynomials, as the constant term in them is gennerally given the subscript 0. In fact, it sounds like you want some form of 1 based indexing, where constant polynomials are degree 1, linear degree 2, etc.
No, I don't want form of 1 based indexing at all :) an array with elements at index 0,1,2,3 has size 4
I don't see how you can view calling a linear polynomial degree 2 an example of 0 based index.