关于很长的位数(位域?) [英] About very long Bit-numbers (bitfields?)
问题描述
嗨
我不知道我是否正在使用正确的单词(位数),但这就是我/ b $ b意思是:
您可以设置64位数字:
unsigned long a;
现在你可以使用二元运算符来操作变量a(例如
a | =(unsigned long)128
)。
怎么样?我想得到例如一个640位长*一个*数字(比如说b)
并对它进行相同的二进制运算(b | = 128)?我还没找到回答
这个...我需要使用Bitfields:
struct BITS
{
unsigned long b1;
unsigned long b2;
unsigned long b3;
....(10时间)
};
我不知道......
Hi
I don''t know if I am using right words (bit-number), but this is what I
mean:
You can set a 64 bit number:
unsigned long a;
Now you can use binary operators to manipulate variable a (for example
a |= (unsigned long) 128
).
How about if I want to get for example a 640 bit long *one* number (say b)
and do the same binary operations to it (b |= 128)? I haven''t found answer
for this ... do I need to use Bitfields:
struct BITS
{
unsigned long b1;
unsigned long b2;
unsigned long b3;
.... (10 times)
};
I don''t know ...
推荐答案
Juha Kettunen< no*@valid.com>这样说了:
Juha Kettunen <no*@valid.com> spoke thus:
如果我想得到一个640位长*一个*数字(比如说b)
并对它进行相同的二进制运算(b) | = 128)?我还没有找到回答
这个...我需要使用Bitfields:
How about if I want to get for example a 640 bit long *one* number (say b)
and do the same binary operations to it (b |= 128)? I haven''t found answer
for this ... do I need to use Bitfields:
你可能会看看vector< bool> ;,虽然我不知道有多有用
你会找到它。
-
Christopher Benson-Manica |我*应该*知道我在说什么 - 如果我
ataru(at)cyberspace.org |不,我需要知道。火焰欢迎。
You might look at vector<bool>, although I have no idea how useful
you''ll find it.
--
Christopher Benson-Manica | I *should* know what I''m talking about - if I
ataru(at)cyberspace.org | don''t, I need to know. Flames welcome.
Juha Kettunen< no*@valid.com>这样说了:
Juha Kettunen <no*@valid.com> spoke thus:
如果我想得到一个640位长*一个*数字(比如说b)
并对它进行相同的二进制运算(b) | = 128)?我还没有找到回答
这个...我需要使用Bitfields:
How about if I want to get for example a 640 bit long *one* number (say b)
and do the same binary operations to it (b |= 128)? I haven''t found answer
for this ... do I need to use Bitfields:
你可能会看看vector< bool> ;,虽然我不知道有多有用
你会找到它。
-
Christopher Benson-Manica |我*应该*知道我在说什么 - 如果我
ataru(at)cyberspace.org |不,我需要知道。火焰欢迎。
You might look at vector<bool>, although I have no idea how useful
you''ll find it.
--
Christopher Benson-Manica | I *should* know what I''m talking about - if I
ataru(at)cyberspace.org | don''t, I need to know. Flames welcome.
On Fri,2004年4月9日10:33:24 +0100,Juha Kettunen < no*@valid.com>写道:
On Fri, 9 Apr 2004 10:33:24 +0100, "Juha Kettunen" <no*@valid.com> wrote:
嗨
我不知道我是否正在使用正确的字(位数),但这就是我
意思是:
你可以设置一个64位的数字:
unsigned long a;
仅供参考,长(无符号或其他)的位数是平台依赖的
。在我的系统上,他们只有32位。但是,这并没有对你真正的问题有多大影响,这就是如何得到/真实/长期的b $ b比特序列。
如果我想获得例如640位长*一个*数字(比如说b)
并对它进行相同的二进制操作(b | = 128)怎么样?我没有找到答案
为此...我需要使用Bitfields:
Hi
I don''t know if I am using right words (bit-number), but this is what I
mean:
You can set a 64 bit number:
unsigned long a;
Just FYI, the number of bits in a long (unsigned or otherwise) is
platform-dependent. On my system they''re only 32 bits. But that doesn''t
have much bearing on your real question, which is how to get /real/ long
bit sequences.
How about if I want to get for example a 640 bit long *one* number (say b)
and do the same binary operations to it (b |= 128)? I haven''t found answer
for this ... do I need to use Bitfields:
为此,克里斯托弗提出了矢量<布尔>可能就足够了。
vector< bool>是黑羊。 STL容器系列...因为它没有满足所有通常的矢量要求:
#include< vector>
int main()
{
std :: vector< char> vc;
std :: vector< bool> vb;
vc.push_back(''x'');
vc.push_back(''y'');
vb.push_back(true);
vb.push_back(true);
std :: vector< char> :: iterator vcit = vc。 begin();
std :: vector< bool> :: iterator vbit = vb.begin();
* vcit =''z'' ; //好的
* vbit = false; //好的
char * cp =& vc [0]; //好的
bool * bp =& vb [0]; //哎呀:不会编译。
返回0;
}
另一方面,它提供了一些专门用于比特的操作
std :: vector< something-other-than-bool>才不是。 Josuttis 6.2.6有
血腥细节。如果你可以避免坑洼,它可能适合你。
-leor
-
Leor Zolman - - BD软件--- www.bdsoft.com
开 - C / C ++,Java,Perl和Unix的现场培训
C ++用户:下载BD Software的免费STL错误消息解密器:
www.bdsoft.com/tools/stlfilt.html
这篇关于关于很长的位数(位域?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!