<分区>
Possible Duplicates:
Query about working out whether number is a power of 2
How to check if a number is a power of 2
我需要这个原型(prototype)的函数体:
bool isPOT(int x);
所以它会返回例如 isPOT(3) = FALSE,但是 isPOT(8) = TRUE
什么是最漂亮/最简洁的算法?什么是最有效的?
PS:我很惊讶我在 SO 上找不到这个问题,所以我完全希望有人能检测到一些重复的问题。
PPS:有人可以创建 POT、NPOT、Power-Of-Two 标签吗?