News for hackers. Stuff that matters.
Re:Sort an array using only one local variable by jmiserez on Saturday April 23, 2016 @07:51AM (#11555160)
The abs() trick works for storing one flag bit. But you can store more than one bit if you shift by N bits left and use the LSBs as flag/boolean bits (then circular shift right + mask when reading). You reduce the range of the local variable by a factor of 2 for every bit stored though (same as the abs trick). Tagged pointers use this method, but instead of shifting one can simply set/clear the bits due to implied alignment:

https://en.wikipedia.org/wiki/Tagged_pointer

Re:Sort an array using only one local variable by prmichaelsen on Saturday April 23, 2016 @09:40PM (#11558217)
Interesting! It never ceases to amaze me what tricks one can pull off with bit manipulation!

Thanks for reading!