return the position of the heightest 1 bit 1-based index
(num uint32)
| 38 | // return the position of the heightest 1 bit |
| 39 | // 1-based index |
| 40 | func highBit(num uint32) uint { |
| 41 | var hiBit uint |
| 42 | for num != 0 { |
| 43 | num >>= 1 |
| 44 | hiBit += 1 |
| 45 | } |
| 46 | return hiBit |
| 47 | } |
| 48 | |
| 49 | // return the position of the lowest 1 bit |
| 50 | // 1-based index |
no outgoing calls
no test coverage detected