用二进制操作 [英] operating with binary

查看:103
本文介绍了用二进制操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我有一个unsigned char数组,但是我需要在

级别压缩它。

例如数组是0x91,0x92,0x93 .. ..

我需要将它改成像10010001 10010010 10010011

....

这样的位流并且一点一点地操作这个流并将其转换为另一个位

stream,

并将该位流转换为unsigned char数组。

我该怎么办?

非常感谢!

解决方案

QQ写道:


您好我有一个unsigned char数组,但是我需要将它压缩到

级别。

例如数组是0x91,0x92,0x93 ....

我需要将它改成像10010001 10010010 10010011

...

的比特流并按此操作此流bit并将其转换为另一位

stream,

并将该位流转换为unsigned char数组。

我该怎么办?



你想要在

两位流之间实现什么转换?取决于它可能没有必要

将其变成比特流。好吧。


说过我不完全清楚你的意思

比特流。也就是为什么你使用压缩这个词。


QQ写道:


就像另一张海报我是不清楚你想做什么。


你好我有一个unsigned char数组,但我需要压缩它在

级别。

例如数组是0x91,0x92,0x93 ....

我需要把它改成像10010001这样的比特流10010010 10010011


你知道一切都已经是二进制了吗? 0x91只是描述二进制数的便捷符号。


并逐位操作此流并进行转换把它改成另一点

stream,



你没有指定...


并将该位流转换为unsigned char数组。

我该怎么办?



如果你想取一个unsigned char数组应用

转换

位数然后你要生成另一个unsigned char数组

可能

想要查看C'的位级运算符。请参阅&,|,^,!,>和<<

(假设

我没有错过任何内容)。


如果你想打印二进制文件,那么你必须用

移位和

掩码来做一些0的序列'和'''''字符。


HTH


-

Nick Keighley


Nick Keighley写道:


如果你想取一个unsigned char数组应用一个

转换

在位级别生成另一个unsigned char数组然后你

可能

想要看看C'的位级运算符。请参阅&,|,^,!,>和<<

(假设

我没有错过任何东西)。



你可能意味着〜而不是!


Hi I have a unsigned char array, but I need to compress it in the bit
level.
for instance the array is 0x91,0x92,0x93....
I need to change it into a bit stream like 10010001 10010010 10010011
....
and operate this stream bit by bit and transform it into another bit
stream,
and convert that bit stream into an unsigned char array.
How can I do it?
Thanks a lot!

解决方案

QQ wrote:

Hi I have a unsigned char array, but I need to compress it in the bit
level.
for instance the array is 0x91,0x92,0x93....
I need to change it into a bit stream like 10010001 10010010 10010011
...
and operate this stream bit by bit and transform it into another bit
stream,
and convert that bit stream into an unsigned char array.
How can I do it?

What is the transformation you want to achieve between the
two bit streams ? Depending on that it may not be necessary
to turn it into a "bit stream" at all.

Having said that I''n not completely clear what you mean by
bit stream. Also why you are using the word compress.


QQ wrote:

like another poster I''m unclear what you want to do.

Hi I have a unsigned char array, but I need to compress it in the bit
level.
for instance the array is 0x91,0x92,0x93....
I need to change it into a bit stream like 10010001 10010010 10010011

you are aware that everything is already in binary? That 0x91 is just a

convenient notation for describing a binary number.

and operate this stream bit by bit and transform it into another bit
stream,

which you fail to specify...

and convert that bit stream into an unsigned char array.
How can I do it?

well if you want to take an array of unsigned char apply a
transformation
at the bit level to produce another array of unsigned char then you
probably
want to look at C''s bit level operators. See &, |, ^, !, >and <<
(assuming
I didn''t miss something).

If you want to print binary then you''ll have to do something with
shifts and
masks to produce a sequence of ''0'' and ''1'' characters.

HTH

--
Nick Keighley


Nick Keighley wrote:

well if you want to take an array of unsigned char apply a
transformation
at the bit level to produce another array of unsigned char then you
probably
want to look at C''s bit level operators. See &, |, ^, !, >and <<
(assuming
I didn''t miss something).

You probably meant ~ instead of !


这篇关于用二进制操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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