3 ms·
Yes, LE is actually the more logical and elegant one, since bit n has weight 2^n, and byte n has a weight 256^n. The BE equivalents introduce an extra length- t
by userbinator 9y ago
Yes, LE is actually the more logical and elegant one, since bit n has weight 2^n, and byte n has a weight 256^n. The BE equivalents introduce an extra length- term into the equation (length-n).
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.)
- TheOtherDave 9y agoOr you could just decrement base.
- PeCaN 9y agoThis 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)
- benaadams 9y ago0-based offsets