I do say I ate zero hamburgers if I just started counting and I have yet to eat one
Comment on call the doctor, the CS doctor
FriendOfElphaba@sh.itjust.works 1 year agoThis.
One of the reasons indexing starts at zero is because back when we used to use pointers and memory addresses, the first byte(s) of an array were at the address where the array was stored. Let’s say it is at 1234. If it was an array of bytes, the first data element was at 1234, or 1234 + 0. The second element would be at 1235, or 1234 + 1. So the first element is at location 0 and the second at location 1, where the index is actually just an offset from the base address. There may be other/better reasons, but that’s what I was taught back in the 90s.
Counting always starts at 1 (if we’re only using integers). You don’t eat a hamburger and say you ate zero hamburgers.
Sonotsugipaa@lemmy.dbzer0.com 1 year ago
FriendOfElphaba@sh.itjust.works 1 year ago
When you’ve eaten more than 50% of the hamburger, do you claim to have eaten one, or do you claim zero? Are you useing standard founding or are you using floor()?
Sonotsugipaa@lemmy.dbzer0.com 1 year ago
I create a Vulkan instance, a device, a compute pipeline then use an image sampler with
VK_FILTER_LINEAR
on a single-texel image in order to interpolate the two adjacent values of hamburger eatage, simple as.
BatmanAoD@programming.dev 1 year ago
“used to”?
FriendOfElphaba@sh.itjust.works 1 year ago
Perchance programming with pointers has plunged as a percentage of programmers.
But thank you. I was hoping someone would notice that.
dukk@programming.dev 1 year ago
Well, you don’t really see many people accessing lists with pointers directly. Also 0-indexing does give us an extra number to index with(say 1-256 vs 0-256)
FriendOfElphaba@sh.itjust.works 1 year ago
It’s 0-255 when you’re indexing like that. 11111111b = 255.
Haus@kbin.social 1 year ago
There was a time when I had to switch back and forth between Fortran90 and C several times a day, and it messed me up so bad doing simple tasks like counting apples at the grocery gave me anxiety.