11-13-2015, 11:51 AM
Need to understand hexadecimal format and flags.
https://en.wikipedia.org/wiki/Hexadecimal
https://en.wikipedia.org/wiki/Flag_field
http://www.quickmacros.com/help/Other/IDP_FLAGS.html
How to read flags from a hexadecimal number:
Each digit (after 0x) is a sum of max four flags at that digit position: 1, 2, 4 and 8.
Examples:
0x5 contains flags 0x4 (4) and 0x1 (1).
0x500 contains flags 0x400 (1024) and 0x100 (256).
0x52A contains flags 0x400, 0x100, 0x20, 0x8 and 0x2.
0x3011 contains flags 0x2000, 0x1000, 0x10 and 0x1.
Table:
Digit - flags
0 - none
1 - 1
2 - 2
3 - 1, 2
4 - 4
5 - 4, 1
6 - 4, 2
7 - 4, 2, 1
8 - 8
9 - 8, 1
A - 8, 2
B - 8, 2, 1
C - 8, 4
D - 8, 4, 1
E - 8, 4, 2
F - 8, 4, 2, 1
How to add a flag:
Simply add the flag value at that position if it does not exist. In code we use operator |, not +. This is to avoid adding when already exists etc.
Example: add flag 0x100 to 0x400: 0x400|0x100. Result: 0x500.
How to remove a flag:
Simply subtract the flag value at that position if it exists. In code we use operator &~ (or just ~ in QM), not -.
Example: remove flag 0x100 from 0x500: 0x500~0x100. Result: 0x400.
Don't translate a hexadecimal flags number like 0x3011 to decimal, it will not have sense. But can translate single flag, for example to write shorter, eg can write 4 instead of 0x4, or 16 instead of 0x10.
https://en.wikipedia.org/wiki/Hexadecimal
https://en.wikipedia.org/wiki/Flag_field
http://www.quickmacros.com/help/Other/IDP_FLAGS.html
How to read flags from a hexadecimal number:
Each digit (after 0x) is a sum of max four flags at that digit position: 1, 2, 4 and 8.
Examples:
0x5 contains flags 0x4 (4) and 0x1 (1).
0x500 contains flags 0x400 (1024) and 0x100 (256).
0x52A contains flags 0x400, 0x100, 0x20, 0x8 and 0x2.
0x3011 contains flags 0x2000, 0x1000, 0x10 and 0x1.
Table:
Digit - flags
0 - none
1 - 1
2 - 2
3 - 1, 2
4 - 4
5 - 4, 1
6 - 4, 2
7 - 4, 2, 1
8 - 8
9 - 8, 1
A - 8, 2
B - 8, 2, 1
C - 8, 4
D - 8, 4, 1
E - 8, 4, 2
F - 8, 4, 2, 1
How to add a flag:
Simply add the flag value at that position if it does not exist. In code we use operator |, not +. This is to avoid adding when already exists etc.
Example: add flag 0x100 to 0x400: 0x400|0x100. Result: 0x500.
How to remove a flag:
Simply subtract the flag value at that position if it exists. In code we use operator &~ (or just ~ in QM), not -.
Example: remove flag 0x100 from 0x500: 0x500~0x100. Result: 0x400.
Don't translate a hexadecimal flags number like 0x3011 to decimal, it will not have sense. But can translate single flag, for example to write shorter, eg can write 4 instead of 0x4, or 16 instead of 0x10.
