Re:Ask HN: Is big-endian dead?
by TheOtherDave on Friday January 19, 2018 @08:51PM
(#16191574)
Or you could just decrement base.
This also conveniently allows you to store the length at the "real" base.
0 array length <--- base pointer
1 element 1 <--- array[1] == *(base + 1)
2 element 2 <--- array[2] == *(base + 2)
I've always found LE vs BE to be somewhat like 0- vs 1-based array indices; one is more "conventional" to a human, but the other doesn't require a lot of contortions when expressed algebraically or algorithmically.
(With 0-based indices, element i is at address base + i * size; with 1-based indices, it's base + (i-1) * size, and it only gets worse from there as you add dimensions and other calculations.)