Just say I have a value of type uint64_t seen as sequence of octets (1 octet = 8-bit). The uint64_t value is known containing only one set bit<
uint64_t
Modern hardware has specialized instructions for that (LZCNT, TZCNT on Intel processors).
Most compilers have intrinsics to easily generate them. See the following wikipedia page.