Skip to content

Instantly share code, notes, and snippets.

@sriramster
sriramster / n_hd.txt
Created October 27, 2013 07:29
Notes from hackers delight
Hacks
+--------------------------------+---------------+-------------------+-----------------------+
|Type |Formula |Example |Code Result |
| | | | |
+--------------------------------+---------------+-------------------+-----------------------+
|1.Test of number being power of |x & (x – 1) |(e.g., 01011000 ⇒ |x = 8 result = 0, x = 9|
|2. | |01010000) |result = 8 |
| | | | |
| | | | |