Hacker News new | past | comments | ask | show | jobs | submit login

It is potentially odd (or even) but nothing compared to everything else when it comes to programming oddities or quirks.

What is the first item in this collection? Oh that would be the one in the box marked zero unless it should be in the one marked ... one!

You mention a circular buffer as an outlier but you simply have to decide where it (the buffer) started off life - 0 or 1 or something else. Make sure that when it is defined, everyone agrees on offsets and off you trot.

No it isn't particularly easy but then bitmaps and blending and sound mixing involve some very involved concepts that are way more complicated than sorting array bounds and worrying about where you are on the Magic Roundabout.




> You mention a circular buffer as an outlier but you simply have to decide where it (the buffer) started off life - 0 or 1 or something else.

No. A circular buffer is just a simple example where you need to go between offsets and locations.

The same theme happens in many similar cases, like directly manipulating bitmaps. E.g. with zero-based indexing into an RGB bitmap:

  bitmap[y*width*3 + x*3] = 1
vs. 1-based indexes:

  bitmap[(y-1)*width*3 + (x-1)*3 + 1] = 1




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: