问题描述
虽然有多种方式来扭转一个字节位顺序,我很好奇,什么是最简单的开发人员来实现。并通过扭转我的意思是:
While there are multiple ways to reverse bit order in a byte, I'm curious as to what is the "simplest" for a developer to implement. And by reversing I mean:
1110 -> 0111
0010 -> 0100
这是类似的,但不是这个 PHP的问题。
This is similar to, but not a duplicate of this PHP question.
此相似,但不this Ç问题。这个问题是要求最简单的方法由开发人员来实现。涉及内存和CPU性能最好的算法。
This is similar to, but not a duplicate of this C question. This question is asking for the easiest method to implement by a developer. The "Best Algorithm" is concerned with memory and cpu performance.
推荐答案
如果你正在谈论一个字节,表查找可能是最好的选择,除非出于某种原因,你没有256字节可用做。
If you are talking about a single byte, a table-lookup is probably the best bet, unless for some reason you don't have 256 bytes available.
这篇关于在C / C ++有什么扭转位的一个字节的顺序最简单的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!