In my workflow, I need to do binary operations quite often. I am wondering if there is a clean way of creating macro/elisp-function to return value of following HASH function.
- Input 16bit hex number: NUM
- Hash function return value = NUM[15] ^ NUM[13] ^ NUM[11] ^ ... ^ NUM[1] (here ^ means XOR)
- For example:
- If NUM(in hex)=0001, hash=0
- if NUM(in hex)=8000, hash=1
- if NUM(in hex)=000A, hash=0
((NUM & 0x55) > 0)?1,0)
in C syntax. i.e. check if any of the odd bits are 1. – Juancho Jun 7 '18 at 18:51