位运算技巧
嗨,
使用按位运算有哪些巧妙的技巧。我知道除非您使用 C 语言编程,否则您不会遇到太多位级操作。尽管如此,您仍然可以在更高级别的语言中应用一些巧妙的技巧。以下是我已经知道的一些。
什么还有其他一些吗?
Possible Duplicate:
What USEFUL bitwise operator code tricks should a developer know about?
Hi,
What are some neat tricks with using bit-wise operations. I know that unless you're programming in C you won't have much encounters with operating on bit level. Nonetheless, there are some neat tricks that you can apply in even higher level languages. Here are a few that I already know.
- bit mask: Can hold a collection of boolean values
- XOR Swap: Swap 2 values in place without a third variable
- XOR Linked List: Create a doubly linked list with each node only hold one address value
What are some others?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
判断一个数是否为奇数
find whether a number is odd or not