反向字节 [英] reverse byte

查看:62
本文介绍了反向字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图反转一个字节,例如。

11010000应该看起来像

00001011

Plz注意,这不是作业问题而且我不需要c代码



请告诉我如何继续关于它。


我知道基本的位操作,左移,右移和已经完成

简单的问题,如计算1'等但这似乎没有to

点击给我。


谢谢。

Kapil

解决方案



" Kapil Khosla" < KH ********* @ yahoo.com>在留言中写道

news:91 ************************** @ posting.google.c om ...


我试图反转一个字节,例如。
11010000应该看起来像
00001011

Plz注意,它不是一个家庭作业问题,我不需要它的代码

请告诉我应该如何处理它。

我知道基本的位操作,左移,对,并做了简单的问题,如计数1'等,但这似乎没有点击给我。

谢谢。
Kapil



创建一个临时字节和AND与掩码0x1的原始字节,以查看是否

在LSB中为1。

如果有一个1然后OR 0x80到临时字节


现在和原始的0x2如果它是1然后OR的临时用0x4

等等。


HTH

Allan


Kapil Khosla< kh*********@yahoo.com>写道:


我试图反转一个字节,例如。
11010000应该看起来像
00001011

Plz注意,它这不是一个家庭作业问题,我不需要它的代码

请告诉我应该如何处理它。




最简单,最清晰,最有效的方法就是使用256个条目的

查询表。


- 凯文。


Kevin Easton写道:

Kapil Khosla< kh ********* @ yahoo.com>写道:
....

我试图反转一个字节,例如。
11010000应该看起来像是00001011

请注意,这不是一个家庭作业问题而且我不需要c代码

请告诉我如何处理它。



http:// graphics .stanford.edu / ~seander / bithacks.html

最简单,最清晰,最有效的方法就是使用256个条目的查找表。




这可能是真的。但它不是很有帮助。

如何生成查找表?你不会手工做,对吗?


Jirka


Hi,
I am trying to reverse a byte eg.
11010000 should look like
00001011

Plz note, it is not a homework problem and I do not need the c code
for it.
Just give me an idea how should I proceed about it.

I know basic bit manipulation , shifting left, right and have done
simple problems like counting 1''s etc but this one doesnt seem to
click to me.

Thanks.
Kapil

解决方案


"Kapil Khosla" <kh*********@yahoo.com> wrote in message
news:91**************************@posting.google.c om...

Hi,
I am trying to reverse a byte eg.
11010000 should look like
00001011

Plz note, it is not a homework problem and I do not need the c code
for it.
Just give me an idea how should I proceed about it.

I know basic bit manipulation , shifting left, right and have done
simple problems like counting 1''s etc but this one doesnt seem to
click to me.

Thanks.
Kapil



Create a temp Byte and AND the original byte with mask 0x1 to see if there
is a 1 in the LSB.
If there is a 1 then OR 0x80 to the temp byte

Now AND the original with 0x2 and if its a 1 then OR the temp with 0x4

And so on.

HTH
Allan


Kapil Khosla <kh*********@yahoo.com> wrote:

Hi,
I am trying to reverse a byte eg.
11010000 should look like
00001011

Plz note, it is not a homework problem and I do not need the c code
for it.
Just give me an idea how should I proceed about it.



The easiest, clearest and most efficient way is just to use a 256-entry
lookup table.

- Kevin.


Kevin Easton wrote:

Kapil Khosla <kh*********@yahoo.com> wrote: ....

I am trying to reverse a byte eg.
11010000 should look like
00001011

Plz note, it is not a homework problem and I do not need the c code
for it.
Just give me an idea how should I proceed about it.



http://graphics.stanford.edu/~seander/bithacks.html
The easiest, clearest and most efficient way is just to use a 256-entry
lookup table.



That might be true. But it''s not very helpful.
How is the lookup table generated? You wouldn''t do this by hand, would you?

Jirka


这篇关于反向字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆