News for hackers. Stuff that matters.
Re:Ask HN: Is big-endian dead? by kazinator on Friday January 19, 2018 @02:48PM (#16189146)
OTOH, big-endian is better for comparison; you can tell when one integer is larger than another by looking at as little as just one bit, from the most significant end.
Re:Ask HN: Is big-endian dead? by ajross on Friday January 19, 2018 @04:13PM (#16189901)
That's only an scalar code optimization though. You can still do comparison in constant time on little endian data, you just lack the ability to early-exit from the loop. In the modern world of SIMD data, that optimization often doesn't exist. Fair enough point though.
Re:Ask HN: Is big-endian dead? by IshKebab on Friday January 19, 2018 @04:07PM (#16189850)
But comparison is done in registers which don't have a byte order. Unless you mean doing something like 256bit_a > 256bit_b which I would think it's a very rare operation. Good point though.
Re:Ask HN: Is big-endian dead? by garmaine on Friday January 19, 2018 @10:49PM (#16191947)
To follow up on this, I recently implemented a packed vector format. As a LE advocate I surprised myself by ordering the packing in BE order — because that let me simply byte-compare vector encodings to compare the underlying vectors, which was a huge performance increase.

Data structures which are frequently compared, e.g. to be sorted, benefit from BE ordering. Just binary compare them as byte strings, usually an efficient inline operation.

If I were implementing a packed wire format for SQL data, for example, I’d probably do it in BE order.

Re:Ask HN: Is big-endian dead? by amelius on Friday January 19, 2018 @04:07PM (#16189855)
In the worst case, comparison is still like subtraction.
Re:Ask HN: Is big-endian dead? by kazinator on Saturday January 20, 2018 @03:00PM (#16195119)
Even if the whole datum is examined, comparison is more parallelizable; it doesn't require carry propagation.