如何得到最后N位都是1的二进制数

这是位运算的一个经典问题:如何得到最后N位都是1的二进制数,

方法是将1左移N位再减一

(1<<N)--;

猜你喜欢

转载自blog.csdn.net/zrh_csdn/article/details/80874410