toggle a bit at ith positon
Possible Duplicate:
How do you set, clear and toggle a single bit in C?
Can some one help me how to toggle a bit at ith position. One way is to ((n>>i)^1) < < i. Are there any other ways ?
n ^= 1U << i
很容易,不是吗?
你可以做
pow(2, i) ^ n
链接地址: http://www.djcxy.com/p/28806.html
上一篇: 如何以C语言存储价值?
下一篇: 在第i个位置切换一下