将32位反转。
uint32_t reverseBits(uint32_t n) { int ret = 0; for (int i = 0; i < 32; ++i) { ret = (ret << 1) + (n & 1); n = n >> 1; } return ret; }
也可以用bitset。
posted on 2018-01-30 00:30 willaty 阅读(90) 评论(0) 编辑 收藏 举报
Powered by: 博客园 Copyright © 2024 willaty Powered by .NET 9.0 on Kubernetes