Skip to content
Archive of posts tagged bitwise

The XOR Linked List In C++

Background It is possible to store the pointers in a linked list in such a way that they ‘overlap’ by using the logical XOR operator.  This allows a user to cut the memory footprint of a basic linked list by 50% at the expense of a couple extra CPU operations.  In today’s world this technique […]

Endianness: Big Endian vs. Little Endian; Shifting and Casting Examples

Background I ran into a bug recently where I was trying to extract the lower 32 bits from a 64 bit pointer referencing two contiguous 32 bit variables in memory.   They were taken out opposite what was expected due to my confusion with the way data is stored.  There is a fairly good writeup […]