[英]Transform byte flags in error status codes to int
I'm confused in bitmasks, bitflags, and other "bit" stuff.我对位掩码、位标志和其他“位”的东西感到困惑。 I have a list of error codes - like
[102, 104, 108, 80000000, 8000000, 10000000, 1000000, 0x0008000, ....]
.我有一个错误代码列表 - 比如
[102, 104, 108, 80000000, 8000000, 10000000, 1000000, 0x0008000, ....]
。 Part of it writing in system logs like bitflags, fe "67108864" (and part of them not, and return normal numbers).它的一部分写入系统日志,如 bitflags、fe "67108864"(其中一部分不是,并返回正常数字)。 I need to match them, but I can not find any algorithm.
我需要匹配它们,但我找不到任何算法。 How I can do that?
我怎么能做到这一点? Maybe it used only for codes like "0x0008000"?
也许它只用于像“0x0008000”这样的代码? If it is true how to define which of this?
如果是真的如何定义这其中的哪一个?
The problem is deeper.问题更深。 I do not understand byte flags.
我不明白字节标志。 I understand that flags usually used for boolean states, but here is logged status codes.
我知道标志通常用于布尔状态,但这里是记录的状态代码。 For example, 102 is (1100110)2.
例如,102 是 (1100110)2。 Byte flag for that number is 2+4+32+64 ... It is how I do transform int to binary form, and it is obviously equal 102. So I'm confused.
该数字的字节标志是 2+4+32+64 ... 这就是我将 int 转换为二进制形式的方式,它显然等于 102。所以我很困惑。
Thanks for your time!谢谢你的时间!
You have to separate你必须分开
numbered error/message codes (usually values in some range like 101, 102, 103...
or in some ranges) - they just specify what error is occured, this error (like "file isn't found") is fully qualified (at least message creators believe :))编号的错误/消息代码(通常是某些范围内的值,如
101, 102, 103...
或某些范围内的值)-它们只是指定发生了什么错误,此错误(如“找不到文件”)是完全限定的(至少消息创建者相信:))
codes containing set of flags (usually written in hex or binary notation if available) - they give us details, every bit contains a piece of information.包含一组标志的代码(如果可用,通常用十六进制或二进制表示法编写)-它们为我们提供详细信息,每一位都包含一条信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.